about the post_save signal and created argument
Posted
by panchicore
on Stack Overflow
See other posts from Stack Overflow
or by panchicore
Published on 2010-03-08T03:52:37Z
Indexed on
2010/03/08
8:21 UTC
Read the original article
Hit count: 259
the docs says:
post_save
django.db.models.signals.post_save
created
A boolean; True if a -new- record was create.
and I have this:
from django.db.models.signals import post_save
def handle_new_user(sender, instance, created, **kwargs):
print "--------> save() "+str(created)
post_save.connect(handle_new_user, sender=User)
when I do in shell:
u = User(username="cat")
u.save()
>>> --------> save() True
u.username = "dog"
u.save()
>>> --------> save() True
I expect a >>> --------> save() False
when I save() the second time because is an update? not?
© Stack Overflow or respective owner