gpt4 book ai didi

python - 类型 Error/login authenticate() 接受 0 到 1 个位置参数,但给出了 2 个

转载 作者:行者123 更新时间:2023-12-04 15:02:26 25 4
gpt4 key购买 nike

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

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

最佳答案

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

if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('pass1')
user = authenticate(<b>username=</b>username, <b>password=</b>password)
# …

关于python - 类型 Error/login authenticate() 接受 0 到 1 个位置参数,但给出了 2 个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66733836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com