不能登陆 login,html
def post(self,request,*args, **kwargs):
''' 获取用户名和密码'''
user_name = request.POST.get("username","")
passowrd = request.POST.get("password","")
user = authenticate(username=user_name,passowrd=passowrd)
if user is not None:
# 查询到用户
login(request,user)
# 登陆用户后,返回页面
# return H(request,'index.html')
return HttpResponseRedirect(reverse("index"))
else:
# 未查询到用户
# return render(request, 'login.html', {"msg": "用户名或密码错误"})
return HttpResponse("登陆失败")