summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2019-12-15 15:30:35 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-27 08:52:40 +0100
commit7fa0fa45c5786619409036c5adce52ff6189b0ac (patch)
treee5cd944e176d80daf8748f1e5cb435344ebdb808 /docs
parent5d654e1e7104d2ce86ec1b9fe52865a7dca4b4be (diff)
Refs #30997 -- Removed HttpRequest.is_ajax() usage.
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/3.1.txt5
-rw-r--r--docs/topics/i18n/translation.txt15
-rw-r--r--docs/topics/testing/tools.txt8
3 files changed, 21 insertions, 7 deletions
diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt
index 3c88ecadd7..09b0b24eec 100644
--- a/docs/releases/3.1.txt
+++ b/docs/releases/3.1.txt
@@ -388,6 +388,11 @@ Miscellaneous
Django 3.1, the first request to any previously cached template fragment will
be a cache miss.
+* The logic behind the decision to return a redirection fallback or a 204 HTTP
+ response from the :func:`~django.views.i18n.set_language` view is now based
+ on the ``Accept`` HTTP header instead of the ``X-Requested-With`` HTTP header
+ presence.
+
* The compatibility imports of ``django.core.exceptions.EmptyResultSet`` in
``django.db.models.query``, ``django.db.models.sql``, and
``django.db.models.sql.datastructures`` are removed.
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index 241dcea660..1dc85d801c 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -1803,9 +1803,18 @@ redirect to that URL will be performed. Otherwise, Django may fall back to
redirecting the user to the URL from the ``Referer`` header or, if it is not
set, to ``/``, depending on the nature of the request:
-* For AJAX requests, the fallback will be performed only if the ``next``
- parameter was set. Otherwise a 204 status code (No Content) will be returned.
-* For non-AJAX requests, the fallback will always be performed.
+* If the request accepts HTML content (based on its ``Accept`` HTTP header),
+ the fallback will always be performed.
+
+* If the request doesn't accept HTML, the fallback will be performed only if
+ the ``next`` parameter was set. Otherwise a 204 status code (No Content) will
+ be returned.
+
+.. versionchanged:: 3.1
+
+ In older versions, the distinction for the fallback is based on whether the
+ ``X-Requested-With`` header is set to the value ``XMLHttpRequest``. This is
+ set by the jQuery ``ajax()`` method.
Here's example HTML template code:
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 2556670904..59f36d44b8 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -159,11 +159,11 @@ Use the ``django.test.Client`` class to make requests.
>>> c = Client()
>>> c.get('/customers/details/', {'name': 'fred', 'age': 7},
- ... HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+ ... HTTP_ACCEPT='application/json')
- ...will send the HTTP header ``HTTP_X_REQUESTED_WITH`` to the
- details view, which is a good way to test code paths that use the
- :meth:`django.http.HttpRequest.is_ajax()` method.
+ ...will send the HTTP header ``HTTP_ACCEPT`` to the details view, which
+ is a good way to test code paths that use the
+ :meth:`django.http.HttpRequest.accepts()` method.
.. admonition:: CGI specification