From 9c9ed6fd7a8399113a18b979c8cd6f04cfbfa30b Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 19 Aug 2025 20:57:32 +0200 Subject: [PATCH] [5.2.x] Refs #35530 -- Corrected deprecation message in auth.alogin(). Follow up to ceecd518b19044181a3598c55ebed7c2545963cc. Backport of b3166e1e15824aedb7a609dfda18ef36ea023d06 from main. --- django/contrib/auth/__init__.py | 2 +- docs/internals/deprecation.txt | 6 +++--- docs/releases/5.2.txt | 6 +++--- tests/async/test_async_auth.py | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index 8e359ec7ff..84ca239558 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -205,7 +205,7 @@ async def alogin(request, user, backend=None): # RemovedInDjango61Warning. if user is None: warnings.warn( - "Fallback to request.user when user is None will be removed.", + "Fallback to request.auser() when user is None will be removed.", RemovedInDjango61Warning, stacklevel=2, ) diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 067686e0e2..ce0348a462 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -18,9 +18,9 @@ details on these changes. * The ``all`` keyword argument of ``django.contrib.staticfiles.finders.find()`` will be removed. -* The fallback to ``request.user`` when ``user`` is ``None`` in - ``django.contrib.auth.login()`` and ``django.contrib.auth.alogin()`` will be - removed. +* Fallbacks to ``request.user`` and ``request.auser()`` when ``user`` is + ``None`` in ``django.contrib.auth.login()`` and + ``django.contrib.auth.alogin()``, respectively, will be removed. * The ``ordering`` keyword argument of the PostgreSQL specific aggregation functions ``django.contrib.postgres.aggregates.ArrayAgg``, diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index feaeb9436a..20d82db98e 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -479,9 +479,9 @@ Miscellaneous * The ``all`` argument for the ``django.contrib.staticfiles.finders.find()`` function is deprecated in favor of the ``find_all`` argument. -* The fallback to ``request.user`` when ``user`` is ``None`` in - ``django.contrib.auth.login()`` and ``django.contrib.auth.alogin()`` will be - removed. +* Fallbacks to ``request.user`` and ``request.auser()`` when ``user`` is + ``None`` in ``django.contrib.auth.login()`` and + ``django.contrib.auth.alogin()``, respectively, are deprecated. * The ``ordering`` keyword argument of the PostgreSQL specific aggregation functions ``django.contrib.postgres.aggregates.ArrayAgg``, diff --git a/tests/async/test_async_auth.py b/tests/async/test_async_auth.py index 3d5a6b678d..f013084b6c 100644 --- a/tests/async/test_async_auth.py +++ b/tests/async/test_async_auth.py @@ -79,7 +79,7 @@ class AsyncAuthTest(TestCase): ), self.assertWarnsMessage( RemovedInDjango61Warning, - "Fallback to request.user when user is None will be removed.", + "Fallback to request.auser() when user is None will be removed.", ), ): await alogin(request, None) @@ -100,7 +100,7 @@ class AsyncAuthTest(TestCase): ), self.assertWarnsMessage( RemovedInDjango61Warning, - "Fallback to request.user when user is None will be removed.", + "Fallback to request.auser() when user is None will be removed.", ), ): await alogin(request, None) @@ -116,7 +116,7 @@ class AsyncAuthTest(TestCase): request.session = await self.client.asession() with self.assertWarnsMessage( RemovedInDjango61Warning, - "Fallback to request.user when user is None will be removed.", + "Fallback to request.auser() when user is None will be removed.", ): await alogin(request, None) user = await aget_user(request)