Skip to content

Commit 1ba439b

Browse files
dcramerrobhudson
authored andcommitted
Ensure if we're overriding the urlconf that we're resetting handler404/500
Signed-off-by: Rob Hudson <[email protected]>
1 parent f3a9b2b commit 1ba439b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

debug_toolbar/middleware.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ def _show_toolbar(self, request):
6767
def process_request(self, request):
6868
if self.show_toolbar(request):
6969
if self.override_url:
70-
original_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
70+
original_urlconf = __import__(getattr(request, 'urlconf', settings.ROOT_URLCONF), {}, {}, ['*'])
7171
debug_toolbar.urls.urlpatterns += patterns('',
7272
('', include(original_urlconf)),
7373
)
74+
if hasattr(original_urlconf, 'handler404'):
75+
debug_toolbar.urls.handler404 = original_urlconf.handler404
76+
if hasattr(original_urlconf, 'handler500'):
77+
debug_toolbar.urls.handler500 = original_urlconf.handler500
7478
self.override_url = False
7579
request.urlconf = 'debug_toolbar.urls'
7680

0 commit comments

Comments
 (0)