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

Replace HttpRequest.is_ajax(), it was removed in Django 4.0 #3264

Open
Tracked by #2788
hmpf opened this issue Jan 27, 2025 · 0 comments · May be fixed by #3265
Open
Tracked by #2788

Replace HttpRequest.is_ajax(), it was removed in Django 4.0 #3264

hmpf opened this issue Jan 27, 2025 · 0 comments · May be fixed by #3265
Assignees
Labels

Comments

@hmpf
Copy link
Contributor

hmpf commented Jan 27, 2025

For #2850

From https://docs.djangoproject.com/en/5.1/releases/3.1/#deprecated-features-3-1:

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant