fix: fix request.is_ajax() deprecation warning (#33055)

* fix: fix request.is_ajax() deprecation warning
This commit is contained in:
Usama Sadiq
2023-08-21 15:59:00 +05:00
committed by GitHub
parent a61e7dc524
commit 3949c73b35
8 changed files with 26 additions and 20 deletions

View File

@@ -102,7 +102,7 @@ def jsonable_server_error(request, template_name='500.html'):
500 error handler that serves JSON on an AJAX request, and proxies
to the Django default `server_error` view otherwise.
"""
if request.is_ajax():
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
msg = {"error": "The edX servers encountered an error"}
return HttpResponseServerError(json.dumps(msg))
else: