Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@adrianholovaty adrianholovaty authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 django/core/handlers/base.py
View
10 django/core/handlers/base.py
@@ -54,12 +54,20 @@ def get_response(self, path, request):
resolver = urlresolvers.RegexURLResolver(r'^/', ROOT_URLCONF)
try:
callback, param_dict = resolver.resolve(path)
+
# Apply view middleware
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, param_dict)
if response:
return response
- return callback(request, **param_dict)
+
+ response = callback(request, **param_dict)
+
+ # Complain if the view returned None (a common error).
+ if not response:
+ raise ValueError, "The view %s.%s didn't return an HttpResponse object." % (callback.__module__, callback.func_name)
+
+ return response
except exceptions.Http404, e:
if DEBUG:
return self.get_technical_error_response(is404=True, exception=e)
Please sign in to comment.
Something went wrong with that request. Please try again.