Fixed #35792 -- Simplified ModelBackend._get_group_permissions().

This commit is contained in:
Bona Fide IT GmbH 2024-09-28 11:36:38 +02:00 committed by Sarah Boyce
parent 470f4c2436
commit d4e4520efb
1 changed files with 1 additions and 3 deletions

View File

@ -99,9 +99,7 @@ class ModelBackend(BaseBackend):
return user_obj.user_permissions.all() return user_obj.user_permissions.all()
def _get_group_permissions(self, user_obj): def _get_group_permissions(self, user_obj):
user_groups_field = get_user_model()._meta.get_field("groups") return Permission.objects.filter(group__in=user_obj.groups.all())
user_groups_query = "group__%s" % user_groups_field.related_query_name()
return Permission.objects.filter(**{user_groups_query: user_obj})
def _get_permissions(self, user_obj, obj, from_name): def _get_permissions(self, user_obj, obj, from_name):
""" """