how to retrieve password in django

后端 未结 5 1145
灰色年华
灰色年华 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条回答
  •  别那么骄傲
    2020-12-15 19:13

    You can check if the password is correct with:

    u.check_password("your password")

    This method and u.set_password("you password") solves all of your problems.

    sha1$f0971$441cac8f604d49869e33ca125a76253a02fef64e is:

    hash function algorithm $ salt $ hash code

提交回复
热议问题