summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornessita <124304+nessita@users.noreply.github.com>2024-10-02 14:21:10 -0300
committerNatalia <124304+nessita@users.noreply.github.com>2024-10-02 14:21:43 -0300
commit6bedb102e9708c6183caa51330f9bdeddf944d6a (patch)
tree446e2e003373105a2dbc44f38e1f0f12068408b3
parentbf64ac3567c892d60d2b157e866c509a37b14918 (diff)
[5.1.x] Reindented attributes and methods for classes in docs/ref/middleware.txt.
Backport of 1feedc8ef8a34484cb5afe33f5c45b543b860210 from main.
-rw-r--r--docs/ref/middleware.txt72
1 files changed, 35 insertions, 37 deletions
diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt
index 738b48f548..2657a8d7ad 100644
--- a/docs/ref/middleware.txt
+++ b/docs/ref/middleware.txt
@@ -34,6 +34,12 @@ defines. See the :doc:`cache documentation </topics/cache>`.
.. class:: CommonMiddleware
+ .. attribute:: response_redirect_class
+
+ Defaults to :class:`~django.http.HttpResponsePermanentRedirect`. Subclass
+ ``CommonMiddleware`` and override the attribute to customize the redirects
+ issued by the middleware.
+
Adds a few conveniences for perfectionists:
* Forbids access to user agents in the :setting:`DISALLOWED_USER_AGENTS`
@@ -75,12 +81,6 @@ Adds a few conveniences for perfectionists:
* Sets the ``Content-Length`` header for non-streaming responses.
-.. attribute:: CommonMiddleware.response_redirect_class
-
-Defaults to :class:`~django.http.HttpResponsePermanentRedirect`. Subclass
-``CommonMiddleware`` and override the attribute to customize the redirects
-issued by the middleware.
-
.. class:: BrokenLinkEmailsMiddleware
* Sends broken link notification emails to :setting:`MANAGERS` (see
@@ -161,16 +161,16 @@ Locale middleware
.. class:: LocaleMiddleware
+ .. attribute:: LocaleMiddleware.response_redirect_class
+
+ Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass
+ ``LocaleMiddleware`` and override the attribute to customize the
+ redirects issued by the middleware.
+
Enables language selection based on data from the request. It customizes
content for each user. See the :doc:`internationalization documentation
</topics/i18n/translation>`.
-.. attribute:: LocaleMiddleware.response_redirect_class
-
-Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass
-``LocaleMiddleware`` and override the attribute to customize the redirects
-issued by the middleware.
-
Message middleware
------------------
@@ -497,6 +497,29 @@ every incoming ``HttpRequest`` object. See :ref:`Authentication in web requests
.. class:: LoginRequiredMiddleware
+ Subclass the middleware and override the following attributes and methods
+ to customize behavior for unauthenticated requests.
+
+ .. attribute:: redirect_field_name
+
+ Defaults to ``"next"``.
+
+ .. method:: get_login_url()
+
+ Returns the URL that unauthenticated requests will be redirected to. This
+ result is either the ``login_url`` set on the
+ :func:`~django.contrib.auth.decorators.login_required` decorator (if not
+ ``None``), or :setting:`settings.LOGIN_URL <LOGIN_URL>`.
+
+ .. method:: get_redirect_field_name()
+
+ Returns the name of the query parameter that contains the URL the user
+ should be redirected to after a successful login. This result is either
+ the ``redirect_field_name`` set on the
+ :func:`~.django.contrib.auth.decorators.login_required` decorator (if not
+ ``None``), or :attr:`redirect_field_name`. If ``None`` is returned, a query
+ parameter won't be added.
+
.. versionadded:: 5.1
Redirects all unauthenticated requests to a login page, except for views
@@ -549,31 +572,6 @@ Customize the login URL or field name for authenticated views with the
:ref:`enabled unauthenticated requests
<disable-login-required-middleware-for-views>` to your login view.
-**Methods and Attributes**
-
-Subclass the middleware and override these to customize behavior for
-unauthenticated requests.
-
-.. attribute:: redirect_field_name
-
- Defaults to ``"next"``.
-
-.. method:: get_login_url()
-
- Returns the URL that unauthenticated requests will be redirected to. This
- result is either the ``login_url`` set on the
- :func:`~django.contrib.auth.decorators.login_required` decorator (if not
- ``None``), or :setting:`settings.LOGIN_URL <LOGIN_URL>`.
-
-.. method:: get_redirect_field_name()
-
- Returns the name of the query parameter that contains the URL the user
- should be redirected to after a successful login. This result is either
- the ``redirect_field_name`` set on the
- :func:`~.django.contrib.auth.decorators.login_required` decorator (if not
- ``None``), or :attr:`redirect_field_name`. If ``None`` is returned, a query
- parameter won't be added.
-
.. class:: RemoteUserMiddleware
Middleware for utilizing web server provided authentication. See