From d4e4520efb553d2bfcc68ac8cf007c0c402d4845 Mon Sep 17 00:00:00 2001 From: Bona Fide IT GmbH <137388433+BonaFideIT@users.noreply.github.com> Date: Sat, 28 Sep 2024 11:36:38 +0200 Subject: [PATCH] Fixed #35792 -- Simplified ModelBackend._get_group_permissions(). --- django/contrib/auth/backends.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index f14fb3e96f78..83525306655b 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -99,9 +99,7 @@ def _get_user_permissions(self, user_obj): return user_obj.user_permissions.all() def _get_group_permissions(self, user_obj): - user_groups_field = get_user_model()._meta.get_field("groups") - user_groups_query = "group__%s" % user_groups_field.related_query_name() - return Permission.objects.filter(**{user_groups_query: user_obj}) + return Permission.objects.filter(group__in=user_obj.groups.all()) def _get_permissions(self, user_obj, obj, from_name): """