Opened 5 years ago
Closed 5 years ago
#31210 closed Cleanup/optimization (fixed)
Document backwards-compatible replacement for is_ajax().
Reported by: | Collin Anderson | Owned by: | Adam Johnson |
---|---|---|---|
Component: | HTTP handling | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | cmawebsite@…, Collin Anderson | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
is_ajax()
was deprecated in #30997.
I think the release/upgrading notes should mention request.is_ajax()
can be replaced with request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
to maintain the old behavior.
Change History (7)
comment:1 by , 5 years ago
Cc: | added |
---|---|
Component: | Documentation → HTTP handling |
Needs documentation: | set |
comment:2 by , 5 years ago
We documented using the HttpRequest.accepts()
or writing a custom AJAX detection method as recommended replacements:
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.
Do you think that we should be so detailed and document the is_ajax()
implementation in release notes? I'm not sure.
comment:3 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 5 years ago
I'm just thinking if someone's trying to upgrade their app to use a new version of django, the most minimal change with the least chance of bugs would be to replace it with request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
(or a separate function/method that does exactly that). Sure, they could refactor their app so it uses .accepts()
, but that's a bigger change (which could involve making changes on the front end, which might be a whole different team responsibly for it) and they're just trying to upgrade django right now.
Do you think that we should be so detailed and document the is_ajax() implementation in release notes? I'm not sure.
Yes, otherwise, they're probably going to need to look it up. Especially considering it's only one line of code, why not make it easy for them?
comment:5 by , 5 years ago
Needs documentation: | unset |
---|---|
Summary: | Document backwards-compatible replacement for is_ajax() → Document backwards-compatible replacement for is_ajax(). |
Triage Stage: | Unreviewed → Accepted |
Agreed, we can add a short snippet to release notes.
comment:6 by , 5 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
In fact, the error message itself could maybe even mention the backwards-compatible replacement.
(I'm hoping this way the upgrade/migration process could be as easy as possible.)