From 8a939224fa5df92f38532c76901975b9e765a1e9 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 18 Aug 2005 00:14:15 +0000 Subject: [PATCH] Added friendly error message if a view returns None instead of an HttpResponse object. git-svn-id: http://code.djangoproject.com/svn/django/trunk@531 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 356e9c45a9..a97a327053 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -54,12 +54,20 @@ class BaseHandler: 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)