def METHOD_NAME(request):
    """Check if requested with XMLHttpRequest
    HttpRequest.is_ajax() was deprecated in Django 3.1
    https://docs.djangoproject.com/en/4.0/releases/3.1/#id2
    """
    return request.headers.get('x-requested-with') == 'XMLHttpRequest'