Skip to content

Commit

Permalink
Only delete the ContentTypes and Permissions once, not the loop (#4623)
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpylog authored and shamoon committed Nov 26, 2023
1 parent 2959ed9 commit 97f69ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/documents/management/commands/document_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def handle(self, *args, **options):
# 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"))
Expand Down

0 comments on commit 97f69ee

Please sign in to comment.