-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix for Django 4.0 removed functions #52
Conversation
Thank you @fraimondo I will merge this soon ;) |
Got a better and more "correct" solution. I'll push it soon. |
Indeed |
Totally agree 😉 |
@fraimondo could you kindly share a link on why request.accepts('application/json') is a suitable replacement for the deprecated is_ajax() ? |
That was actually a hard one: django/django#12091 By digging in the PR and the associated ticket |
@fraimondo I tried to merge this PR but got the following exception:
runnng the example project with Django v 3.0.8 and Python 3.8.11 By inspecting the requests namespaces, accepts() seems to be missing, indeed: ipdb> dir(request) Any suggestion ? |
Indeed I just figured out it's specific for Django 4.0. I can think of creating |
@fraimondo According to https://stackoverflow.com/questions/63629935/django-3-1-and-is-ajax I fixed this with following function in def is_ajax(request):
return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' |
The main issue with this approach is that it is exactly why they deprecated and later removed it. The X-Requested-With heather is nonstandard and set by JQuery. |
then why not using either |
That was my plan, but I did not have time to take care of that yet. I’ll do it soon.
… On 16 Dec 2021, at 19:17, morlandi ***@***.***> wrote:
then why not using either request.accepts('application/json') or request.is_ajax() depending on the version of Django as detected at run-time ?
—
Reply to this email directly, view it on GitHub <#52 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABCJDA5E7GT6IDBCBKXHEB3URIULRANCNFSM5FLDHL3A>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.
|
never mind, take your time 😉 |
I finally opted for this:
|
This PR makes is compatible with Django 4.0.