4
views.py:如何成參數傳遞給一個信號
user = User.objects.create_user(username=username, email=email)
user.password=password1
#user.set_password(password1)
user.save()
models.py:
def create_user_profile(sender, instance, created, **kwargs):
if created:
#here i want user password unencrypted where I pass that parameter to this
signal
post_save.connect(create_user_profile, sender=User)
注意,Django的發送者總是類,而不是實例。實際上,您可以將任何東西作爲發件人傳遞,但最好以與Django本身相同的方式執行此操作。 – simplylizz 2012-07-19 09:20:56
@simplylizz是的,我解決它,謝謝。 – xiaowl 2012-07-19 09:31:24