Skip to main content
 首页 » 编程设计

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

2025年05月04日27shanyou

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'])