From 8cf3114defb3678c5dd2710e0a7d8502de73f071 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 7 Apr 2026 12:42:51 +0200 Subject: [PATCH 1/3] Removed outdated note about uwsgi LTS from docs. projects.unbit.it has an invalid certificate and provides old packages. --- docs/howto/deployment/wsgi/uwsgi.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/howto/deployment/wsgi/uwsgi.txt b/docs/howto/deployment/wsgi/uwsgi.txt index 2bb49b285c61..144b8261525a 100644 --- a/docs/howto/deployment/wsgi/uwsgi.txt +++ b/docs/howto/deployment/wsgi/uwsgi.txt @@ -27,9 +27,6 @@ command. For example: # Install current stable version. $ python -m pip install uwsgi - # Or install LTS (long term support). - $ python -m pip install https://projects.unbit.it/downloads/uwsgi-lts.tar.gz - .. _installation procedures: https://uwsgi-docs.readthedocs.io/en/latest/Install.html uWSGI model From 74e73dc1315d696330621a7f08310a2e87ea0eba Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 7 Apr 2026 13:03:37 +0200 Subject: [PATCH 2/3] Updated Apache links to the current docs. --- docs/howto/deployment/wsgi/apache-auth.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/howto/deployment/wsgi/apache-auth.txt b/docs/howto/deployment/wsgi/apache-auth.txt index b9270695435f..58cb28439334 100644 --- a/docs/howto/deployment/wsgi/apache-auth.txt +++ b/docs/howto/deployment/wsgi/apache-auth.txt @@ -5,7 +5,7 @@ How to authenticate against Django's user database from Apache Since keeping multiple authentication databases in sync is a common problem when dealing with Apache, you can configure Apache to authenticate against Django's :doc:`authentication system ` directly. This -requires Apache version >= 2.2 and mod_wsgi >= 2.0. For example, you could: +requires Apache version >= 2.2 and ``mod_wsgi`` >= 2.0. For example, you could: * Serve static/media files directly from Apache only to authenticated users. @@ -23,7 +23,7 @@ requires Apache version >= 2.2 and mod_wsgi >= 2.0. For example, you could: auth handler if your custom cannot conform to these requirements. .. _Subversion: https://subversion.apache.org/ -.. _mod_dav: https://httpd.apache.org/docs/2.2/mod/mod_dav.html +.. _mod_dav: https://httpd.apache.org/docs/current/mod/mod_dav.html Authentication with ``mod_wsgi`` ================================ @@ -66,7 +66,7 @@ password that it receives from the prompt. In this example, the application :doc:`that is created by django-admin startproject `. -.. admonition:: Using Apache 2.2 with authentication +.. admonition:: Using Apache 2.2+ with authentication Make sure that ``mod_auth_basic`` and ``mod_authz_user`` are loaded. From e2abe321a6f1370e05c1a89a742125c9eafcac8c Mon Sep 17 00:00:00 2001 From: mariatta Date: Fri, 3 Apr 2026 11:44:02 -0700 Subject: [PATCH 3/3] Fixed #37021 -- Added Permission.user_perm_str property. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For use in checking user permissions via has_perm(). Co-authored-by: 사재혁 --- django/contrib/auth/models.py | 5 +++++ docs/ref/contrib/auth.txt | 10 ++++++++++ docs/releases/6.1.txt | 3 +++ docs/topics/auth/default.txt | 9 +++++++++ tests/auth_tests/test_models.py | 4 ++++ 5 files changed, 31 insertions(+) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 7b7dee78fc4e..f41ece7ce894 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -79,6 +79,11 @@ class Meta: def __str__(self): return "%s | %s" % (self.content_type, self.name) + @property + def user_perm_str(self): + """String representation for the user permission check.""" + return f"{self.content_type.app_label}.{self.codename}" + def natural_key(self): return (self.codename, *self.content_type.natural_key()) diff --git a/docs/ref/contrib/auth.txt b/docs/ref/contrib/auth.txt index ff16de64233e..b09b55cdda00 100644 --- a/docs/ref/contrib/auth.txt +++ b/docs/ref/contrib/auth.txt @@ -405,6 +405,16 @@ Methods :class:`~django.contrib.auth.models.Permission` objects have the standard data-access methods like any other :doc:`Django model `. +.. class:: models.Permission + :noindex: + + .. attribute:: user_perm_str + + .. versionadded:: 6.1 + + Returns the string representation for use in :meth:`has_perm + `. + ``Group`` model =============== diff --git a/docs/releases/6.1.txt b/docs/releases/6.1.txt index 9c8aeea70c3d..00eaf5388d05 100644 --- a/docs/releases/6.1.txt +++ b/docs/releases/6.1.txt @@ -129,6 +129,9 @@ Minor features * :attr:`.Permission.name` and :attr:`.Permission.codename` values are now renamed when renaming models via a migration. +* The new :attr:`.Permission.user_perm_str` property returns the string + suitable to use with :meth:`.User.has_perm`. + :mod:`django.contrib.contenttypes` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt index 77888febb326..83925d009f18 100644 --- a/docs/topics/auth/default.txt +++ b/docs/topics/auth/default.txt @@ -243,6 +243,15 @@ to test for basic permissions you should use: The :class:`~django.contrib.auth.models.Permission` model is rarely accessed directly. +The :class:`~django.contrib.auth.models.Permission` model provides a helper +property, :attr:`~django.contrib.auth.models.Permission.user_perm_str`, +that returns the string representation that can be used to check permission +using the :meth:`~django.contrib.auth.models.User.has_perm` method. + +.. versionchanged:: 6.1 + + The ``user_perm_str`` property was added. + Groups ------ diff --git a/tests/auth_tests/test_models.py b/tests/auth_tests/test_models.py index a3e7a3205beb..fd99b970d756 100644 --- a/tests/auth_tests/test_models.py +++ b/tests/auth_tests/test_models.py @@ -635,3 +635,7 @@ def test_str(self): self.assertEqual( str(p), "Auth_Tests | custom email field | Can view custom email field" ) + + def test_user_perm_str(self): + p = Permission.objects.get(codename="view_customemailfield") + self.assertEqual(p.user_perm_str, "auth_tests.view_customemailfield")