-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Hi 👋
On upgrade to Django 4.2 in our project and using django-selectable==1.4.0 a problem is present with the @ajax_required decorator where it is using the removed is_ajax method.
https://github.com/mlavin/django-selectable/blob/master/selectable/decorators.py#L44-L47
This was removed in Django 4.0 here https://docs.djangoproject.com/en/4.2/releases/4.0/#features-removed-in-4-0
Notes from Django 3.1 deprecation notice:
The HttpRequest.is_ajax() method is deprecated as it relied on a jQuery-specific way of signifying AJAX calls, while current usage tends to use the JavaScript Fetch API. Depending on your use case, you can either write your own AJAX detection method, or use the new HttpRequest.accepts() method if your code depends on the client Accept HTTP header.
If you are writing your own AJAX detection method, request.is_ajax() can be reproduced exactly as request.headers.get('x-requested-with') == 'XMLHttpRequest'.