Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 类型错误/login authenticate()接受0到1个位置参数,但给出了2个_Python_Django_Authentication - Fatal编程技术网

Python 类型错误/login authenticate()接受0到1个位置参数,但给出了2个

Python 类型错误/login authenticate()接受0到1个位置参数,但给出了2个,python,django,authentication,Python,Django,Authentication,每当我在登录页面上输入凭据时,就会出现此错误,我的登录功能也被命名为loginUser,但是您需要将凭据作为命名参数传递: def loginUser(request): if request.method == "POST": username = request.POST.get('username') password = request.POST.get('pass1') user = authenticate(

每当我在登录页面上输入凭据时,就会出现此错误,我的登录功能也被命名为loginUser,但是

您需要将凭据作为命名参数传递:

def loginUser(request):
    if request.method == "POST":
        username = request.POST.get('username')
        password = request.POST.get('pass1')
        user = authenticate(username, password)

        if user is not None:
            login(request, user)
            return redirect( '/')

        else:
            messages.error(request, "Either your email or password is wrong!")
            return render(request, 'loginpage.html')
    return render(request, 'loginpage.html')
if request.method==“POST”:
username=request.POST.get('username')
密码=request.POST.get('pass1')
用户=验证(用户名=用户名,密码=密码)

#…
谢谢你的帮助
if request.method == 'POST':
    username = request.POST.get('username')
    password = request.POST.get('pass1')
    user = authenticate(username=username, password=password)
    # …