2

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.

3
  • use return in the last else condition Commented Jul 22, 2017 at 14:07
  • Its working now thanks. Commented Jul 22, 2017 at 14:10
  • I will post it as an answer so that it might be helpful for others. Commented Jul 22, 2017 at 14:12

1 Answer 1

3

Your function doesn't return anything when it executes the last else condition you should add a return statements.

return render(request , 'zdorovo/login.html' , {}) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.