diff options
| author | Rob Hudson | 2008-10-02 22:42:51 -0700 | 
|---|---|---|
| committer | Rob Hudson | 2008-10-02 22:42:51 -0700 | 
| commit | 60e49ecf7c800cc6001ac0e3112434a6f931bcd6 (patch) | |
| tree | 93e8f476739a27af5f46853db6e2cd0c02636ec5 /debug_toolbar/middleware.py | |
| parent | 04be402d080877abbc18931cb853933261fb332f (diff) | |
| parent | b66c950d4cb8672a924f9652224772d7219abbe2 (diff) | |
| download | django-debug-toolbar-60e49ecf7c800cc6001ac0e3112434a6f931bcd6.tar.bz2 | |
Merge branch 'urlfix'
Diffstat (limited to 'debug_toolbar/middleware.py')
| -rw-r--r-- | debug_toolbar/middleware.py | 15 | 
1 files changed, 6 insertions, 9 deletions
| diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index cfa8590..9dd9954 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -30,6 +30,9 @@ class DebugToolbarMiddleware(object):      """      def __init__(self):          self.debug_toolbar = None +        self.original_urlconf = settings.ROOT_URLCONF +        self.original_pattern = patterns('', ('', include(self.original_urlconf)),) +        self.override_url = True      def show_toolbar(self, request):          if not settings.DEBUG: @@ -41,15 +44,9 @@ class DebugToolbarMiddleware(object):          return True      def process_request(self, request): -        # Monkeypatch in the URLpatterns for the debug toolbar. The last item -        # in the URLpatterns needs to be ```('', include(ROOT_URLCONF))``` so -        # that the existing URLs load *after* the ones we patch in. However, -        # this is difficult to get right: a previous middleware might have -        # changed request.urlconf, so we need to pick that up instead. -        original_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF) -        debug_toolbar.urls.urlpatterns += patterns('', -            ('', include(original_urlconf)), -        ) +        if self.override_url: +            debug_toolbar.urls.urlpatterns += self.original_pattern +            self.override_url = False          request.urlconf = 'debug_toolbar.urls'          if self.show_toolbar(request): | 
