diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 35eceee5c..06a574a03 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -77,11 +77,11 @@ def __call__(self, request): getattr(response, "streaming", False), "gzip" in content_encoding, content_type not in _HTML_TYPES, - request.is_ajax(), + not request.accepts("text/html"), ) ): # If a AJAX or JSON request, render the toolbar for the history. - if request.is_ajax() or content_type == "application/json": + if not request.accepts("text/html") or content_type == "application/json": toolbar.render_toolbar() return response