aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/middleware.py
diff options
context:
space:
mode:
authorRob Hudson2008-09-20 17:09:16 -0700
committerRob Hudson2008-09-20 17:09:16 -0700
commita6abeef6a5a734ad28178f939560dd127c363544 (patch)
treef9762f3536bba875eaa29e07af134ece369aa84b /debug_toolbar/middleware.py
parentf40ad85645f27fc4b80683acdbefd01a1da51afd (diff)
downloaddjango-debug-toolbar-a6abeef6a5a734ad28178f939560dd127c363544.tar.bz2
Patch from Alex Gaynor that fixes jQuery conflicts with Pinax and potentially
other projects.
Diffstat (limited to 'debug_toolbar/middleware.py')
-rw-r--r--debug_toolbar/middleware.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index 9170398..9c8581c 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -10,7 +10,8 @@ from debug_toolbar.toolbar.loader import DebugToolbar
_HTML_TYPES = ('text/html', 'application/xhtml+xml')
_END_HEAD_RE = re.compile(r'</head>', re.IGNORECASE)
-_END_BODY_RE = re.compile(r'<body([^<]*)>', re.IGNORECASE)
+_START_BODY_RE = re.compile(r'<body([^<]*)>', re.IGNORECASE)
+_END_BODY_RE = re.compile(r'</body>', re.IGNORECASE)
class DebugToolbarMiddleware(object):
"""
@@ -54,5 +55,6 @@ class DebugToolbarMiddleware(object):
if response['Content-Type'].split(';')[0] in _HTML_TYPES:
# Saving this here in case we ever need to inject into <head>
#response.content = _END_HEAD_RE.sub(smart_str(self.debug_toolbar.render_styles() + "%s" % match.group()), response.content)
- response.content = _END_BODY_RE.sub(smart_str('<body\\1>' + self.debug_toolbar.render_toolbar()), response.content)
+ response.content = _START_BODY_RE.sub(smart_str('<body\\1>' + self.debug_toolbar.render_toolbar()), response.content)
+ response.content = _END_BODY_RE.sub(smart_str('<script src="' + request.META.get('SCRIPT_NAME', '') + '/__debug__/m/toolbar.js" type="text/javascript" charset="utf-8"></script></body>'), response.content)
return response