authenticate总是返回None

自己对参考链接中的代码进行了扩展,完整如下:

Python 3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 21:14:29) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> eml = "[email protected]"
>>> pw = "pass"
>>> uname = 'w2'
>>> from user.models import User
>>> user = User.objects.create_user(uname,eml,pw)
>>> user.save()
>>> user.check_password(pw)
True
>>> from django.contrib.auth import authenticate
>>> user = authenticate(username=uname, password=pw)
>>> user
<User: w2>
 

发布了785 篇原创文章 · 获赞 357 · 访问量 166万+

猜你喜欢

转载自blog.csdn.net/appleyuchi/article/details/105043724
今日推荐