Skip to content

Commit 405e562

Browse files
committed
Ensure we honor request.urlconf.
Previously, the debug toolbar would always bolt on URLs from ROOT_URLCONF, which would break another middleware if it inserts URLs onto request.urlconf.
1 parent 930669f commit 405e562

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

debug_toolbar/middleware.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class DebugToolbarMiddleware(object):
3333
"""
3434
def __init__(self):
3535
self.debug_toolbars = {}
36-
self.original_urlconf = settings.ROOT_URLCONF
37-
self.original_pattern = patterns('', ('', include(self.original_urlconf)),)
3836
self.override_url = True
3937

4038
# Set method to use to decide to show toolbar
@@ -59,7 +57,10 @@ def _show_toolbar(self, request):
5957
def process_request(self, request):
6058
if self.show_toolbar(request):
6159
if self.override_url:
62-
debug_toolbar.urls.urlpatterns += self.original_pattern
60+
original_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
61+
debug_toolbar.urls.urlpatterns += patterns('',
62+
('', include(original_urlconf)),
63+
)
6364
self.override_url = False
6465
request.urlconf = 'debug_toolbar.urls'
6566

0 commit comments

Comments
 (0)