4

视图.py:

user = User.objects.create_user(username=username, email=email)          
user.password=password1
#user.set_password(password1)
user.save()

模型.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) 
4

1 回答 1

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')
于 2012-07-19T09:14:00.027 回答