It inspects the non-standard header X-Requested-Wiith that is set by
jQuery and maybe other frameworks. However jQuery's popularity, especially
for making requests, is decreasing thanks to changes such as the new
`fetch()` JS API.
Also in the cases this property is used to determine the kind of content
to send to a client, it'd be better to inspect the HTTP standard `Accept`
header.
For these reasons Flask has deprecated its similar property `is_xhr`.
--
Ticket URL: <https://code.djangoproject.com/ticket/30997>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Old description:
> As discussed on [this django-developers
> thread](https://groups.google.com/d/msg/django-
> developers/F8F5b1kEA34/FhqCmRw9BwAJ) this should be deprecated.
>
> It inspects the non-standard header X-Requested-Wiith that is set by
> jQuery and maybe other frameworks. However jQuery's popularity,
> especially for making requests, is decreasing thanks to changes such as
> the new `fetch()` JS API.
>
> Also in the cases this property is used to determine the kind of content
> to send to a client, it'd be better to inspect the HTTP standard `Accept`
> header.
>
> For these reasons Flask has deprecated its similar property `is_xhr`.
New description:
As discussed on [https://groups.google.com/d/msg/django-
developers/F8F5b1kEA34/FhqCmRw9BwAJ this django-developers thread] this
should be deprecated.
It inspects the non-standard header X-Requested-Wiith that is set by
jQuery and maybe other frameworks. However jQuery's popularity, especially
for making requests, is decreasing thanks to changes such as the new
`fetch()` JS API.
Also in the cases this property is used to determine the kind of content
to send to a client, it'd be better to inspect the HTTP standard `Accept`
header.
For these reasons Flask has deprecated its similar property `is_xhr`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:1>
Comment (by Claude Paroz):
The first step would be to document current limitations of the method.
Second step would be to avoid using it as much as possible in Django's own
code.
Finally the deprecation can take place.
It remains to be shown how the
[https://github.com/django/django/pull/12091 request.accepts] proposal can
play a role here.
A good exercise would be to replace that example:
https://docs.djangoproject.com/en/2.2/topics/class-based-views/generic-
editing/#ajax-example (or would you simply remove it?)
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:2>
* has_patch: 0 => 1
Comment:
I modified a bit the [https://github.com/django/django/pull/12091
requests.accept() PR] to include what is IMHO needed before deprecating
the `is_ajax` method.
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:3>
Comment (by sobelek):
By deprecate do you just mean removing it from code base?
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:4>
Comment (by Adam (Chainz) Johnson):
Yes, via a standard deprecation as per the policy:
https://docs.djangoproject.com/en/dev/internals/release-process/#internal-
release-deprecation-policy
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d66d72f95655312c413d916add61a62928639514" d66d72f]:
{{{
#!CommitTicketReference repository=""
revision="d66d72f95655312c413d916add61a62928639514"
Refs #30997 -- Added HttpRequest.accepts().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"7fa0fa45c5786619409036c5adce52ff6189b0ac" 7fa0fa4]:
{{{
#!CommitTicketReference repository=""
revision="7fa0fa45c5786619409036c5adce52ff6189b0ac"
Refs #30997 -- Removed HttpRequest.is_ajax() usage.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:7>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"e348ab0d4382b0d7cb0cab9d1261c916c3d0ce6c" e348ab0]:
{{{
#!CommitTicketReference repository=""
revision="e348ab0d4382b0d7cb0cab9d1261c916c3d0ce6c"
Fixed #30997 -- Deprecated HttpRequest.is_ajax().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:8>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"c9bf1910e2c1a72244dbd1e3dd9a3ff7215b8b4a" c9bf191]:
{{{
#!CommitTicketReference repository=""
revision="c9bf1910e2c1a72244dbd1e3dd9a3ff7215b8b4a"
Refs #30997 -- Added link to Fetch API in release notes.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:9>
Comment (by GitHub <noreply@…>):
In [changeset:"7fc317ae736e8fda1aaf4d4ede84d95fffaf5281" 7fc317a]:
{{{
#!CommitTicketReference repository=""
revision="7fc317ae736e8fda1aaf4d4ede84d95fffaf5281"
Refs #30997 -- Improved HttpRequest.is_ajax() warning message with
stacklevel=2.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"619e3db7d5fca54afbd9c4e0905b59571989fc6f" 619e3db]:
{{{
#!CommitTicketReference repository=""
revision="619e3db7d5fca54afbd9c4e0905b59571989fc6f"
[3.1.x] Refs #30997 -- Improved HttpRequest.is_ajax() warning message with
stacklevel=2.
Backport of 7fc317ae736e8fda1aaf4d4ede84d95fffaf5281 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:11>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"d08977a0f05cf3efb538dcb09d07915d2ede4c67" d08977a0]:
{{{
#!CommitTicketReference repository=""
revision="d08977a0f05cf3efb538dcb09d07915d2ede4c67"
Refs #30997 -- Removed HttpRequest.is_ajax() per deprecation timeline.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:12>