about the post_save signal and created argument
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_sa开发者_StackOverflow中文版ve
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?
Seems like you have implemented your own User which doesn't have a unique constraint on username?
I suggest you use User.objects.create_user
to avoid bulk operation.
精彩评论