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?
我建议您使用User.objects.create_user
避免批量操作。
似乎您已经实现了自己的用户,而用户名没有唯一的限制?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.