Skip to content

Commit

Permalink
Fixed #35792 -- Simplified ModelBackend._get_group_permissions().
Browse files Browse the repository at this point in the history
  • Loading branch information
BonaFideIT authored and sarahboyce committed Oct 9, 2024
1 parent 470f4c2 commit d4e4520
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions django/contrib/auth/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit d4e4520

Please sign in to comment.