Here is my views.py
views.py
def user_login(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username = username , password = password)
if user:
if user.is_active:
login(request , user)
return HttpResponseRedirect('/zdorovo/')
else:
return HttpResponse('You dont have an account with us')
else:
print "Invalid Login Details: {0} , {1}".format(username , password)
return HttpResponse('Invalid Login Details ')
else:
render(request , 'zdorovo/login.html' , {})
authenticate , login , HttpResponse , HttpResponseRedirect have been imported correctly. I also took care of Indentation , so the error is not raising from that end. Please help me understand the error.
Here is my login.html
<body>
<h1>Login</h1>
<form id="login_id" method="post" action="/zdorovo/login/">
{% csrf_token %}
Username: <input type="text" name="username" value=""/>
<br/>
Password: <input type="password" name="password" value=""/>
<br/>
<input type="submit" value="Login" />
</form>
</body>
P.S.:- Update me if you need other scripts from my end.
return
in the lastelse
condition – badiya