Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The view didn't return an HttpResponse object. It returned None instead

I have the following simple view. Why is it resulting in this error?

The view auth_lifecycle.views.user_profile didn't return an HttpResponse object. It returned None instead.

"""Renders web pages for the user-authentication-lifecycle project.""" from django.shortcuts               import render from django.template                import RequestContext from django.contrib.auth            import authenticate, login  def user_profile(request):     """Displays information unique to the logged-in user."""      user = authenticate(username='superuserusername', password='sueruserpassword')     login(request, user)      render(request, 'auth_lifecycle/user_profile.html',            context_instance=RequestContext(request)) 
like image 372
aliteralmind Avatar asked Oct 08 '14 14:10

aliteralmind


1 Answers

Because the view must return render, not just call it. Change the last line to

return render(request, 'auth_lifecycle/user_profile.html',            context_instance=RequestContext(request)) 
like image 175
3 revs, 3 users 86% Avatar answered Sep 21 '22 07:09

3 revs, 3 users 86%