[Solved] I’ve trying to build a simple login page for my project


Your logic isn’t good, if user is not None: instead use if user.is_anonymous:

Try my logic

def login(request):
c = {}
c.update(csrf(request))
return render_to_response(request,
'login.html', c)

def auth_view(request):
username = request.POST.get
('username', '')
password = request.POST.get
('password', '')
user = auth.authenticate
(username = username, password =
password)
if user.is_anonymous:
auth.login(request,user)
if request.method == 'POST':
return HttpResponseRedirect('accounts/loggedin/')
else:
return HttpResponseRedirect('accounts/invalid/')

Note: Your return is in caps

Now it should work. Try it!!

solved I’ve trying to build a simple login page for my project