diff options
| author | Aymeric Augustin | 2013-11-15 20:17:30 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-15 20:33:51 +0100 |
| commit | b6e2027d1b2e481c2595d2a85042c27202818feb (patch) | |
| tree | a6b824eea60aba7b6ec479968385240232e429d5 | |
| parent | 70d3aa1b8c12d614f2ca1b1b550bb605d8c8a506 (diff) | |
| download | django-debug-toolbar-b6e2027d1b2e481c2595d2a85042c27202818feb.tar.bz2 | |
Disable the toolbar entirely on AJAX requests.
| -rw-r--r-- | debug_toolbar/middleware.py | 5 | ||||
| -rw-r--r-- | docs/configuration.rst | 9 |
2 files changed, 9 insertions, 5 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 7456072..edcf17f 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -40,6 +40,9 @@ def show_toolbar(request): if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS: return False + if request.is_ajax(): + return False + return bool(settings.DEBUG) @@ -87,7 +90,7 @@ class DebugToolbarMiddleware(object): def process_response(self, request, response): __traceback_hide__ = True # noqa toolbar = self.__class__.debug_toolbars.pop(threading.current_thread().ident, None) - if not toolbar or request.is_ajax() or getattr(response, 'streaming', False): + if not toolbar or getattr(response, 'streaming', False): return response if isinstance(response, HttpResponseRedirect): if not toolbar.config['INTERCEPT_REDIRECTS']: diff --git a/docs/configuration.rst b/docs/configuration.rst index d8cf9a9..df203cb 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -84,10 +84,11 @@ Toolbar options If set to ``None``, the debug toolbar middleware will use its built-in ``show_toolbar`` method for determining whether the toolbar should show or - not. The default checks are that ``DEBUG`` must be set to ``True`` and the - IP of the request must be in ``INTERNAL_IPS``. You can provide your own - method for displaying the toolbar which contains your custom logic. This - method should return ``True`` or ``False``. + not. The default checks are that ``DEBUG`` must be set to ``True``, the IP + of the request must be in ``INTERNAL_IPS``, and the request must no be an + AJAX request. You can provide your own method for displaying the toolbar + which contains your custom logic. This method should return ``True`` or + ``False``. * ``TAG`` |
