1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[2.2.x] Fixed #30330 -- Fixed setting of primary key to None during fast-delete.

Regression in bc7dd8490b.

Backport of afc708cf6d from master
This commit is contained in:
Florian Apolloner
2019-04-05 17:52:59 +02:00
committed by Mariusz Felisiak
parent 53c83387cf
commit b88ffef7ea
3 changed files with 13 additions and 0 deletions

View File

@@ -278,6 +278,7 @@ class Collector:
if self.can_fast_delete(instance):
with transaction.mark_for_rollback_on_error():
count = sql.DeleteQuery(model).delete_batch([instance.pk], self.using)
setattr(instance, model._meta.pk.attname, None)
return count, {model._meta.label: count}
with transaction.atomic(using=self.using, savepoint=False):