[Django] #30997: Deprecate HttpRequest.is_ajax

40 views
Skip to first unread message

Django

unread,
Nov 17, 2019, 5:36:03 PM11/17/19
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax
-------------------------------------------------+------------------------
Reporter: Adam (Chainz) Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+------------------------
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`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30997>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 18, 2019, 2:27:50 AM11/18/19
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* 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>

Django

unread,
Nov 18, 2019, 3:39:36 AM11/18/19
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 15, 2019, 10:10:55 AM12/15/19
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* 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>

Django

unread,
Jan 18, 2020, 4:20:00 PM1/18/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by sobelek):

By deprecate do you just mean removing it from code base?

--
Ticket URL: <https://code.djangoproject.com/ticket/30997#comment:4>

Django

unread,
Jan 19, 2020, 10:48:20 AM1/19/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 24, 2020, 8:48:49 AM1/24/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 27, 2020, 3:56:14 AM1/27/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 27, 2020, 3:56:15 AM1/27/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: closed
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* 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>

Django

unread,
Jan 28, 2020, 3:06:04 AM1/28/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: closed
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 3, 2020, 2:47:37 AM6/3/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: closed
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jun 3, 2020, 2:48:50 AM6/3/20
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: closed
Cleanup/optimization |
Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Jan 14, 2021, 2:12:17 PM1/14/21
to django-...@googlegroups.com
#30997: Deprecate HttpRequest.is_ajax.
--------------------------------------+------------------------------------
Reporter: Adam Johnson | Owner: nobody
Type: Cleanup/optimization | Status: closed

Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages