Skip to content

Commit 783781c

Browse files
authored
Merge pull request #1253 from jdufresne/ajax
Remove use of deprecated request.is_ajax()
2 parents a8ffb63 + 0672df7 commit 783781c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

debug_toolbar/middleware.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
from functools import lru_cache
77

8+
import django
89
from django.conf import settings
910
from django.utils.module_loading import import_string
1011

@@ -48,7 +49,11 @@ def __call__(self, request):
4849
# Decide whether the toolbar is active for this request. Don't render
4950
# the toolbar during AJAX requests.
5051
show_toolbar = get_show_toolbar()
51-
if not show_toolbar(request) or request.is_ajax():
52+
if not show_toolbar(request) or (
53+
request.is_ajax()
54+
if django.VERSION < (3, 1)
55+
else not request.accepts("text/html")
56+
):
5257
return self.get_response(request)
5358

5459
toolbar = DebugToolbar(request, self.get_response)

0 commit comments

Comments
 (0)