1
0
mirror of https://github.com/django/django.git synced 2025-03-13 10:50:55 +00:00

[5.1.x] Reindented attributes and methods for classes in docs/ref/middleware.txt.

Backport of 1feedc8ef8a34484cb5afe33f5c45b543b860210 from main.
This commit is contained in:
nessita 2024-10-02 14:21:10 -03:00 committed by Natalia
parent bf64ac3567
commit 6bedb102e9

View File

@ -34,6 +34,12 @@ defines. See the :doc:`cache documentation </topics/cache>`.
.. class:: CommonMiddleware .. 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: Adds a few conveniences for perfectionists:
* Forbids access to user agents in the :setting:`DISALLOWED_USER_AGENTS` * 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. * 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 .. class:: BrokenLinkEmailsMiddleware
* Sends broken link notification emails to :setting:`MANAGERS` (see * Sends broken link notification emails to :setting:`MANAGERS` (see
@ -161,15 +161,15 @@ Locale middleware
.. class:: LocaleMiddleware .. class:: LocaleMiddleware
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 .. attribute:: LocaleMiddleware.response_redirect_class
Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass
``LocaleMiddleware`` and override the attribute to customize the redirects ``LocaleMiddleware`` and override the attribute to customize the
issued by the middleware. 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>`.
Message middleware Message middleware
------------------ ------------------
@ -497,6 +497,29 @@ every incoming ``HttpRequest`` object. See :ref:`Authentication in web requests
.. class:: LoginRequiredMiddleware .. 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 .. versionadded:: 5.1
Redirects all unauthenticated requests to a login page, except for views 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 :ref:`enabled unauthenticated requests
<disable-login-required-middleware-for-views>` to your login view. <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 .. class:: RemoteUserMiddleware
Middleware for utilizing web server provided authentication. See Middleware for utilizing web server provided authentication. See