From 11ed59dc298c893f733a9faf8ca2219303b0553d Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:25:07 -0800 Subject: [PATCH] Only delete the ContentTypes and Permissions once, not the loop --- src/documents/management/commands/document_importer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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"))