aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt George2008-09-07 12:25:44 -0700
committerMatt George2008-09-07 12:25:44 -0700
commit0e6b811d36960848888bcf5211fbcea04f394803 (patch)
treedc4346e4b68e16e7f514303e3dec34fc161c744c
parentb03b091ef0f1fffea3390d01fc4a70c8f29bcc30 (diff)
parentb4f14501ca759a7bdcc553c3c97a60819f904cdc (diff)
downloaddjango-debug-toolbar-0e6b811d36960848888bcf5211fbcea04f394803.tar.bz2
Merge branch 'master' of git://github.com/robhudson/django-debug-toolbar
Conflicts: debug_toolbar/middleware.py
-rw-r--r--README.rst11
-rw-r--r--debug_toolbar/middleware.py13
2 files changed, 19 insertions, 5 deletions
diff --git a/README.rst b/README.rst
index 63743bb..0e557dc 100644
--- a/README.rst
+++ b/README.rst
@@ -13,6 +13,7 @@ Currently, the following panels have been written and are working:
- Django version
- SQL queries including time to execute
- Request timer
+- Common HTTP headers
If you have ideas for other panels please let us know.
@@ -37,6 +38,7 @@ Installation
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
+ 'debug_toolbar.panels.headers.HeaderDebugPanel',
)
You can change the ordering of this tuple to customize the order of the
@@ -45,11 +47,16 @@ Installation
#. Add `debug_toolbar` to your `INSTALLED_APPS` setting so Django can find the
the template files associated with the Debug Toolbar.
+#. The UI effects of the Toolbar currently depend on jQuery to be already
+ included in your templates. So currently to test out the toolbar jQuery
+ already needs to be loaded on the page. We'll need a solution for this at
+ some point.
+
TODO
====
- Add more panels
- Panel idea: Show some commonly used settings from settings.py
- Panel idea: Show GET and POST variables
-- Panel idea: Show HTTP header information
- Panel idea: AJAX call to show cprofile data similar to the ?prof idea
-- Get fancy with CSS and Javascript
+- CSS Stylings
+- Remove dependency on jQuery and come up with a general workable solution.
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index 7ef90d0..870dbb8 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -18,14 +18,21 @@ class DebugToolbarMiddleware(object):
def __init__(self):
self.debug_toolbar = None
+ def show_toolbar(self, request):
+ if not settings.DEBUG:
+ return False
+ if not request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
+ return False
+ return True
+
def process_request(self, request):
- self.debug_toolbar = DebugToolbar(request)
- if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
+ if self.show_toolbar(request):
+ self.debug_toolbar = DebugToolbar(request)
self.debug_toolbar.load_panels()
return None
def process_response(self, request, response):
- if settings.DEBUG:
+ if self.show_toolbar(request):
if response['Content-Type'].split(';')[0] in _HTML_TYPES and not request.is_ajax():
#response.content = _END_HEAD_RE.sub(mark_safe(self.debug_toolbar.render_styles() + "%s" % match.group()), response.content)
response.content = _END_BODY_RE.sub(mark_safe(self.debug_toolbar.render_toolbar() + '</body>'), response.content)