Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added friendly error message if a view returns None instead of an Htt…

…pResponse object.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@531 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8a939224fa5df92f38532c76901975b9e765a1e9 1 parent f5ab132
Adrian Holovaty authored August 18, 2005

Showing 1 changed file with 9 additions and 1 deletion. Show diff stats Hide diff stats

  1. 10  django/core/handlers/base.py
10  django/core/handlers/base.py
@@ -54,12 +54,20 @@ def get_response(self, path, request):
54 54
         resolver = urlresolvers.RegexURLResolver(r'^/', ROOT_URLCONF)
55 55
         try:
56 56
             callback, param_dict = resolver.resolve(path)
  57
+
57 58
             # Apply view middleware
58 59
             for middleware_method in self._view_middleware:
59 60
                 response = middleware_method(request, callback, param_dict)
60 61
                 if response:
61 62
                     return response
62  
-            return callback(request, **param_dict)
  63
+
  64
+            response = callback(request, **param_dict)
  65
+
  66
+            # Complain if the view returned None (a common error).
  67
+            if not response:
  68
+                raise ValueError, "The view %s.%s didn't return an HttpResponse object." % (callback.__module__, callback.func_name)
  69
+
  70
+            return response
63 71
         except exceptions.Http404, e:
64 72
             if DEBUG:
65 73
                 return self.get_technical_error_response(is404=True, exception=e)

0 notes on commit 8a93922

Please sign in to comment.
Something went wrong with that request. Please try again.