![](/img/trans.png)
[英]Why isn't django.contrib.auth.authenticate() working here?
[英]Why does the Django django.contrib.auth.authenticate need in-place arguments?
为什么Django身份验证功能仅与此兼容?
user=authenticate(
username=request.POST['username'],
password=request.POST['password']
)
而不是
user=authenticate(
request.POST['username'],
request.POST['password']
)
可以有许多不同的身份验证后端,它们使用的身份验证方式可能不同于使用用户名和密码(即某种令牌)的身份验证方式。 为了使authenticate()
方法保持通用,必须以这种方式实现。
官方文档说:“默认情况下,它将凭据作为关键字参数, 用户名和密码 。” 关键部分是: 对于默认情况 。
可以作为位置参数给出的唯一参数是可选的request
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.