diff --git a/opencivicdata/management/commands/loaddivisions.py b/opencivicdata/management/commands/loaddivisions.py index 14abb78..b989dc3 100644 --- a/opencivicdata/management/commands/loaddivisions.py +++ b/opencivicdata/management/commands/loaddivisions.py @@ -37,7 +37,14 @@ def load_divisions(country): # delete old ids and add new ones all at once with transaction.atomic(): Division.objects.filter(country=country).delete() - Division.objects.bulk_create(objects, batch_size=10000) + for object_ in objects: + object_.save() + # Division.objects.bulk_create(objects, batch_size=10000) + # XXX: The above line (bulk_create) ends up causing pk consistency + # issues when doing an update, even though we did a delete + # and the PK is clear. The .save() on each shockingly + # works. I'm switching this until this is entirely + # understood. print(len(objects), 'divisions created')