aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cramer2011-04-18 16:52:43 -0700
committerRob Hudson2011-04-25 11:09:25 -0700
commit1ba439bff713560b0aa5340bd25c57bdc8152d5f (patch)
tree97574af392f8f690ee43c45e31482261ae01e44d
parentf3a9b2b58bb468f65a5d5de2a5f8cb4b5ffe8b67 (diff)
downloaddjango-debug-toolbar-1ba439bff713560b0aa5340bd25c57bdc8152d5f.tar.bz2
Ensure if we're overriding the urlconf that we're resetting handler404/500
Signed-off-by: Rob Hudson <rob@cogit8.org>
-rw-r--r--debug_toolbar/middleware.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index 232d887..7f0f4bc 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -67,10 +67,14 @@ class DebugToolbarMiddleware(object):
def process_request(self, request):
if self.show_toolbar(request):
if self.override_url:
- original_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
+ original_urlconf = __import__(getattr(request, 'urlconf', settings.ROOT_URLCONF), {}, {}, ['*'])
debug_toolbar.urls.urlpatterns += patterns('',
('', include(original_urlconf)),
)
+ if hasattr(original_urlconf, 'handler404'):
+ debug_toolbar.urls.handler404 = original_urlconf.handler404
+ if hasattr(original_urlconf, 'handler500'):
+ debug_toolbar.urls.handler500 = original_urlconf.handler500
self.override_url = False
request.urlconf = 'debug_toolbar.urls'