diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index d103f32..934c3e3 100644
a
|
b
|
class ModelBackend(object):
|
30 | 30 | if user_obj.is_superuser: |
31 | 31 | perms = Permission.objects.all() |
32 | 32 | else: |
33 | | perms = Permission.objects.filter(group__user=user_obj) |
| 33 | related_query_name = get_user_model()._meta.get_field('groups').related_query_name() |
| 34 | filters = {'group__%s' % related_query_name: user_obj} |
| 35 | perms = Permission.objects.filter(**filters) |
34 | 36 | perms = perms.values_list('content_type__app_label', 'codename').order_by() |
35 | 37 | user_obj._group_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms]) |
36 | 38 | return user_obj._group_perm_cache |