mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
f5ab1320ed
commit
8a939224fa
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue