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)
答案 0 :(得分:1)
发送信号
有两种方法可以在Django中发送发送信号。
Signal.send(sender, **kwargs)
Signal.send_robust(sender, **kwargs)
https://docs.djangoproject.com/en/dev/topics/signals/#sending-signals
在你的情况下,你可能会做这样的事情
# not the real word code.
Signal.send(User, raw_password="xxx")
# raw password stays in **kwargs
def create_user_profile(sender, instance, created, **kwargs):
if created:
//here i want user password unencrypted where I pass that parameter to this
raw_pass = kwargs.get('raw_password')