1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[5.1.x] Refs #31405 -- Improved LoginRequiredMiddleware documentation.

co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>

Backport of 49815f70e4 from main.
This commit is contained in:
Adam Johnson
2024-08-08 07:10:13 +01:00
committed by Sarah Boyce
parent d9aeb23edb
commit 291fa5fbbe
3 changed files with 47 additions and 17 deletions

View File

@@ -91,12 +91,15 @@ redirects all unauthenticated requests to a login page. Views can allow
unauthenticated requests by using the new
:func:`~django.contrib.auth.decorators.login_not_required` decorator.
The :class:`~django.contrib.auth.middleware.LoginRequiredMiddleware` respects
the ``login_url`` and ``redirect_field_name`` values set via the
``LoginRequiredMiddleware`` respects the ``login_url`` and
``redirect_field_name`` values set via the
:func:`~.django.contrib.auth.decorators.login_required` decorator, but does not
support setting ``login_url`` or ``redirect_field_name`` via the
:class:`~django.contrib.auth.mixins.LoginRequiredMixin`.
To enable this, add ``"django.contrib.auth.middleware.LoginRequiredMiddleware"``
to your :setting:`MIDDLEWARE` setting.
Minor features
--------------