Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 4.2 issue related to is_ajax usage #228

Open
peteyb opened this issue Nov 8, 2023 · 0 comments
Open

Django 4.2 issue related to is_ajax usage #228

peteyb opened this issue Nov 8, 2023 · 0 comments

Comments

@peteyb
Copy link

peteyb commented Nov 8, 2023

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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant