django表单登录不起作用

时间:2014-05-15 13:56:27

标签: django forms authentication login

我已尝试在注册页面注册用户 但是当我尝试登录系统时,它会提醒我'密码不正确',但我确信它是正确的。我该怎么办?

这是登录视图

def login_detail(request):
error = []
form = loginform()
if request.method=="POST":
    form = loginform(request.POST)
    if form.is_valid():
        data = form.cleaned_data
        user_name = data['user_name']
        user_pwd = data['user_pwd']
        if login_validate(request,user_name,user_pwd):
            return render_to_response("detail.html",{'username':user_name})
        else:
            error.append("Please input the correct username and password")
    else:
        error.append("Please input both the usename and the password")


return render_to_response("login.html",{'error':error,'form':form})

0 个答案:

没有答案