From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Fri, 17 Nov 2023 20:24:49 +0000 (-0800) Subject: Only delete the ContentTypes and Permissions once, not the loop (#4623) X-Git-Tag: v2.0.0~3^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a94e5d2e4706b7c6b107a0f6d5d57c26a4f76ca2;p=thirdparty%2Fpaperless-ngx.git Only delete the ContentTypes and Permissions once, not the loop (#4623) --- diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.py index 7a3e40f28c..9895104c3c 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"))