我一直在寻找一种存储散列的方法,但是我仍然没有在model.py中找到正确的方法来存储散列。
models.py
class QL_USR_DT(models.Model):
ql_usr_img_link=models.ImageField(upload_to="user-profile-picture")
ql_usr_name=models.CharField(max_length=60)
ql_usr_email=models.EmailField()#By default the max_Length is 254
ql_usr_pass=models.CharField(max_length=254)
ql_usr_username=models.CharField(max_length=30)
gender = (
("M","Male"),
("F","Female"),
)
ql_usr_gender = models.CharField(max_length=1, choices=gender, default="M", null=False)
ql_usr_created=models.DateTimeField(auto_now_add=True)
settings.py
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
]
答案 0 :(得分:0)
如果您真的想在自己的模型中自行管理密码,则可以执行以下操作:
from django.contrib.auth.hashers import make_password, check_password
your_password = make_password("plain_text")
check_password("plain_text",your_password)
并将该哈希存储在数据库中。