python - Django 类型错误 : authenticate() takes exactly 0 arguments (3 given)

标签 python django django-1.10

Django 版本 1.10.7

我收到 TypeError: authenticate() takes exactly 0 arguments (3 given)

像这样导入 authenticate():
from django.contrib.auth import authenticate, login

像这样调用 authenticate() :
验证(请求,username=request.POST['username'],password=request.POST['password'])

最佳答案

在 1.10 中 authenticate 不接受位置参数 ( docs ) 称之为

authenticate(username=request.POST['username'], password=request.POST['password'])

关于python - Django 类型错误 : authenticate() takes exactly 0 arguments (3 given),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45927704/

相关文章:

python - Django:图像/绝对 URL 不显示在 html 中

python - 使用 python docker sdk 登录到 ecr registry 无法按预期工作

python - 在一个线程中拥有deque和Queue的优点

python - 如果django模型已经有相关类,如何将其转换为抽象模型

python - Django:无法解析相关模型 'users.UserProfile'

python - CSRF 验证失败 - 请求中止

具有复杂类型的 Python 枚举

python - 如何在 Python 中将十六进制字符串转换为整数?

django - 为 Django 测试的输出着色

Django:通过另一个多对多关系访问多对多对象