Django is telling me that my login view isn’t returning an HttpResponse object:
The view accounts.views.login didn't return an HttpResponse object.
However, I’m using render_to_response() everywhere and there is no way the view could finish resolving without getting a response. Here’s the code:
def login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
auth_login(request, user)
render_to_response('list.html')
else:
error = "It seems your account has been disabled."
render_to_response('list.html', {'error': error})
else:
error = "Bad login information. Give it another go."
render_to_response('list.html', {'error': error})
else:
error = "Bad login information. Give it another go."
render_to_response('list.html', {'error': error})
else:
error = "Whoa, something weird happened. You sure you're using the form on our site?"
render_to_response('list.html', {'error': error})
I’m sure the code could be more efficient (less renders), but this should work, correct?
You are missing the return