aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debug_toolbar/middleware.py9
-rw-r--r--debug_toolbar/templates/debug_toolbar/redirect.html14
2 files changed, 23 insertions, 0 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index 44a8b9d..58712d9 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -3,6 +3,8 @@ Debug Toolbar middleware
"""
import re
from django.conf import settings
+from django.http import HttpResponseRedirect
+from django.shortcuts import render_to_response
from django.utils.encoding import smart_str
from django.conf.urls.defaults import include, patterns
import debug_toolbar.urls
@@ -57,6 +59,13 @@ class DebugToolbarMiddleware(object):
def process_response(self, request, response):
if not self.debug_toolbar:
return response
+ if isinstance(response, HttpResponseRedirect):
+ redirect_to = response.get('Location', None)
+ if redirect_to:
+ response = render_to_response(
+ 'debug_toolbar/redirect.html',
+ {'redirect_to': redirect_to}
+ )
if response.status_code != 200:
return response
for panel in self.debug_toolbar.panels:
diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html
new file mode 100644
index 0000000..b61286e
--- /dev/null
+++ b/debug_toolbar/templates/debug_toolbar/redirect.html
@@ -0,0 +1,14 @@
+<html>
+<head>
+</head>
+<body>
+<h1>HttpResponseRedirect</h1>
+<p>Location: <a href="{{ redirect_to }}">{{ redirect_to }}</a></p>
+<p class="notice">
+ The Django Debug Toolbar has intercepted a redirect to the above URL for
+ debug viewing purposes. You can click the above link to continue with the
+ redirect as normal. If you'd like to disable this feature, set the config
+ property <code>INTERCEPT_REDIRECTS</code> to <code>False</code>.
+</p>
+</body>
+</html>