Django version 1.10.7
Django的类型错误:身份验证()恰恰0参数(3给出)
我越来越TypeError: authenticate() takes exactly 0 arguments (3 given)
导入身份验证()是这样的:
from django.contrib.auth import authenticate, login
调用验证()像这样:
authenticate(request, username=request.POST['username'] ,password=request.POST['password'])
https://docs.djangoproject.com/en/1.11/topics/auth/default/#how-to-log-a-user-in:在给出的例子中,使用的身份验证类似于'user = authenticate(request, username = username,password = password)' – batMan
@batMan确实,但要注意版本。在1.11 Django增加了一个可选的请求参数,但1.10没有。 – chicocvenancio
好吧所以这只是在1.11中可选。说得通。我只是试过,它的工作。希望我可以在这里接受所有3个答案。无论如何,我已经upvoted所有这些。感谢您的快速回答。 – batMan