aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
authorRob Hudson2008-09-20 16:09:01 -0700
committerRob Hudson2008-09-20 16:09:01 -0700
commit7677c7e39c56a040dfb523169fcaa7d58645d2b8 (patch)
treef5a47088554ae9eac77a2c22c043dcc1d4607768 /debug_toolbar
parent344c60d81eb265088e58efd07fff51983232cde4 (diff)
downloaddjango-debug-toolbar-7677c7e39c56a040dfb523169fcaa7d58645d2b8.tar.bz2
Turn back on if request.is_ajax check but put the monkey patching of URLs in no
matter what so our actual views (for ajax) can be run.
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/middleware.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index eebd5a2..9170398 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -23,28 +23,28 @@ class DebugToolbarMiddleware(object):
def show_toolbar(self, request):
if not settings.DEBUG:
return False
- #if request.is_ajax():
- # return False
+ if request.is_ajax():
+ return False
if not request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
return False
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)),
+ )
+ request.urlconf = 'debug_toolbar.urls'
+
if self.show_toolbar(request):
self.debug_toolbar = DebugToolbar(request)
self.debug_toolbar.load_panels()
-
- # 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)),
- )
- request.urlconf = 'debug_toolbar.urls'
-
+
return None
def process_response(self, request, response):