python - django authenticate 返回结果一直是None

# 不论怎么测试 authenticate 返回结果一直是None,查了查原因好像是 django 2.1 版本的问题

( 我用的是 2.1.7)

解决方法:

1. 先导入

from django.contrib.auth.hashers import check_password

2. 按照步骤,数据库查询用户名,判断密码,判断用户是否存在,最后返回结果

 

posted @ 2019-03-24 14:36  _Q  阅读(1480)  评论(0编辑  收藏  举报