fix: fix request.is_ajax() deprecation warning (#33055)
* fix: fix request.is_ajax() deprecation warning
This commit is contained in:
@@ -18,7 +18,7 @@ def jsonable_error(status=500, message="The Studio servers encountered an error"
|
||||
def outer(func):
|
||||
@functools.wraps(func)
|
||||
def inner(request, *args, **kwargs):
|
||||
if request.is_ajax():
|
||||
if request.headers.get('x-requested-with') == 'XMLHttpRequest':
|
||||
content = dump_js_escaped_json({"error": message})
|
||||
return HttpResponse(content, content_type="application/json", # lint-amnesty, pylint: disable=http-response-with-content-type-json
|
||||
status=status)
|
||||
|
||||
@@ -94,7 +94,7 @@ class MaintenanceBaseView(View):
|
||||
"""
|
||||
A short method to render_to_response that renders response.
|
||||
"""
|
||||
if self.request.is_ajax():
|
||||
if self.request.headers.get('x-requested-with') == 'XMLHttpRequest':
|
||||
return JsonResponse(self.context)
|
||||
return render_to_response(self.template, self.context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user