diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 3986257660a..5d6b36439bd 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -128,7 +128,8 @@ class BaseHandler(object): view_name = callback.__name__ else: # CBV view_name = callback.__class__.__name__ + '.__call__' - raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name)) + raise ValueError("The view %s.%s didn't return an HttpResponse object. It returned None instead." + % (callback.__module__, view_name)) # If the response supports deferred rendering, apply template # response middleware and then render the response diff --git a/tests/middleware_exceptions/tests.py b/tests/middleware_exceptions/tests.py index b11986d4d0d..406f0f8fea6 100644 --- a/tests/middleware_exceptions/tests.py +++ b/tests/middleware_exceptions/tests.py @@ -382,7 +382,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest): self._add_middleware(middleware) self._add_middleware(pre_middleware) self.assert_exceptions_handled('/middleware_exceptions/null_view/', [ - "The view middleware_exceptions.views.null_view didn't return an HttpResponse object.", + "The view middleware_exceptions.views.null_view didn't return an HttpResponse object. It returned None instead.", ], ValueError()) @@ -399,7 +399,7 @@ class MiddlewareTests(BaseMiddlewareExceptionTest): self._add_middleware(middleware) self._add_middleware(pre_middleware) self.assert_exceptions_handled('/middleware_exceptions/null_view/', [ - "The view middleware_exceptions.views.null_view didn't return an HttpResponse object." + "The view middleware_exceptions.views.null_view didn't return an HttpResponse object. It returned None instead." ], ValueError()) @@ -693,7 +693,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest): self._add_middleware(bad_middleware) self._add_middleware(pre_middleware) self.assert_exceptions_handled('/middleware_exceptions/null_view/', [ - "The view middleware_exceptions.views.null_view didn't return an HttpResponse object.", + "The view middleware_exceptions.views.null_view didn't return an HttpResponse object. It returned None instead.", 'Test Response Exception' ]) @@ -710,7 +710,7 @@ class BadMiddlewareTests(BaseMiddlewareExceptionTest): self._add_middleware(bad_middleware) self._add_middleware(pre_middleware) self.assert_exceptions_handled('/middleware_exceptions/null_view/', [ - "The view middleware_exceptions.views.null_view didn't return an HttpResponse object." + "The view middleware_exceptions.views.null_view didn't return an HttpResponse object. It returned None instead." ], ValueError())