Fixed #5559: instances sent via post-save signals no longer have pks of None. Thanks, Joseph Kocherhans.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6411 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4edecaeae9
commit
960c1263b6
|
@ -1180,7 +1180,7 @@ def delete_objects(seen_objs):
|
||||||
if field.rel and field.null and field.rel.to in seen_objs:
|
if field.rel and field.null and field.rel.to in seen_objs:
|
||||||
setattr(instance, field.attname, None)
|
setattr(instance, field.attname, None)
|
||||||
|
|
||||||
setattr(instance, cls._meta.pk.attname, None)
|
|
||||||
dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance)
|
dispatcher.send(signal=signals.post_delete, sender=cls, instance=instance)
|
||||||
|
setattr(instance, cls._meta.pk.attname, None)
|
||||||
|
|
||||||
transaction.commit_unless_managed()
|
transaction.commit_unless_managed()
|
||||||
|
|
|
@ -54,7 +54,7 @@ Is updated
|
||||||
pre_delete signal, Tom Smith
|
pre_delete signal, Tom Smith
|
||||||
instance.id is not None: True
|
instance.id is not None: True
|
||||||
post_delete signal, Tom Smith
|
post_delete signal, Tom Smith
|
||||||
instance.id is None: True
|
instance.id is None: False
|
||||||
|
|
||||||
>>> p2 = Person(first_name='James', last_name='Jones')
|
>>> p2 = Person(first_name='James', last_name='Jones')
|
||||||
>>> p2.id = 99999
|
>>> p2.id = 99999
|
||||||
|
@ -73,7 +73,7 @@ Is created
|
||||||
pre_delete signal, James Jones
|
pre_delete signal, James Jones
|
||||||
instance.id is not None: True
|
instance.id is not None: True
|
||||||
post_delete signal, James Jones
|
post_delete signal, James Jones
|
||||||
instance.id is None: True
|
instance.id is None: False
|
||||||
|
|
||||||
>>> Person.objects.all()
|
>>> Person.objects.all()
|
||||||
[<Person: James Jones>]
|
[<Person: James Jones>]
|
||||||
|
|
Loading…
Reference in New Issue