<pre>
def login(request):
if request.method == "GET":
return render(request, 'login.html')
elif request.method == "POST":
username = request.POST.get('username','')
password = request.POST.get('password','')
print username, password
result = models.UserInfo.objects.filter(user=username,password=password)
resulta = models.UserInfo.objects.filter(user=username,password=password).first()
if result:
print result
print resulta
else:
return HttpResponse('用户名或密码错误')
return render(request, 'index.html', {'result': result})</pre>
热门评论