【发布时间】:2012-05-07 03:48:54
【问题描述】:
在将我的 django 安装从 1.2.3 升级到 1.4 后,我无法再使用 authenticate() 方法。
check_password() 函数工作正常,但我可以在数据库的正确表中看到加密密码。
>>> from django.contrib.auth.models import User
>>> u = User(username='joe', password='password')
>>> u.set_password('password')
>>> u.save()
>>> from django.contrib.auth import authenticate
>>> user = authenticate(username='joe', password='password')
>>> user # this is None
>>> u.check_password('password')
>>> True
>>> u.check_password('passwordxxxx')
>>> False
我的身份验证后端是正常的.. 在实验中我特别添加了:
AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
我相信这是默认设置。
我不知道如何才能看到问题出在哪里......有什么想法吗?
干杯
-我
【问题讨论】:
-
您是否使用任何自定义身份验证后端?
-
嗨霍夫.. 不,编辑问题以包含更多信息
-
多么尴尬..我的机器由于不同的原因崩溃了,并且在重新启动后执行上述代码有效。道歉霍夫! :|.. 我会标记明天回答的问题(现在不允许)
-
正要建议重新加载!
标签: django