diff options
| -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`` | 
