how to retrieve password in django

后端 未结 5 1134
灰色年华
灰色年华 2020-12-15 18:16

How do we retrieve a password of an user?

u = User.objects.get(username__exact=username)
print u.password

displays sha1$f0971$441cac8

5条回答
  •  Happy的楠姐
    2020-12-15 18:50

    Due to security restrictions the password hash method is one way. You will need to reset that users password.

    Try using the set_password(raw_password) method to give the user a new password. Remember to call the save() method to ensure you save the change to the database.

    u = User.objects.get(username__exact=username)
    u.set_password(raw_password)
    u.save()
    

提交回复
热议问题