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): """