Fixed #21912 -- Improved error message if a view returns None.
Thanks brycenesbitt for the report.
This commit is contained in:
parent
d97bf2e9c8
commit
1150053b99
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue