Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Only delete the ContentTypes and Permissions once, not the loop (#4623)

Trenton Ha94e5d2e4706
diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.py
index 7a3e40f28..9895104c3 100644
--- a/src/documents/management/commands/document_importer.py
+++ b/src/documents/management/commands/document_importer.py
@@ -118,10 +118,10 @@ class Command(BaseCommand):
# Fill up the database with whatever is in the manifest
try:
with transaction.atomic():
+ # delete these since pk can change, re-created from import
+ ContentType.objects.all().delete()
+ Permission.objects.all().delete()
for manifest_path in manifest_paths:
- # delete these since pk can change, re-created from import
- ContentType.objects.all().delete()
- Permission.objects.all().delete()
call_command("loaddata", manifest_path)
except (FieldDoesNotExist, DeserializationError, IntegrityError) as e:
self.stdout.write(self.style.ERROR("Database import failed"))