Trying to make my app reusable and compatible with custom user models, I've encountered the following issue:

Let's say the User model is the following:

```
class Member(AbstractUser):
    pass   # basically the builtin User with another name

```

As a result of this code from `django.contrib.auth.models`:

```
class PermissionsMixin(models.Model):
    """
    A mixin class that adds the fields and methods necessary to support
    Django's Group and Permission model using the ModelBackend.
    """
    is_superuser = models.BooleanField(_('superuser status'), default=False,
        help_text=_('Designates that this user has all permissions without '
                    'explicitly assigning them.'))
    groups = models.ManyToManyField(Group, verbose_name=_('groups'),
        blank=True, help_text=_('The groups this user belongs to. A user will '
                                'get all permissions granted to each of '
                                'his/her group.'))
    user_permissions = models.ManyToManyField(Permission,
        verbose_name=_('user permissions'), blank=True,
        help_text='Specific permissions for this user.')

class AbstractUser(AbstractBaseUser, PermissionsMixin):  # <- included there
    ....

```

(Notice that the many to many `groups` doesn't define a `related_name`.)

Now, when working with groups I can't do this:

```
group.user_set.add(...)

```

because the reverse `RelatedManager` name is actually `member_set`.

Note that the the model's name is `Member` in this case but it could be any other.

Right now, I'm doing the following:

```
getattr(group, "%s_set" % settings.AUTH_USER_MODEL.split('.')[-1].lower())

```

Yeah, quite ugly.

Question: Any common or bultin solution for this?

**EDIT with my final implementation:**

```
@classmethod
def _get_user_reverse_field_name(cls):
    User = get_user_model()
    cls._user_reverse_field_name = User._meta.get_field('groups').related.get_accessor_name()

@property
def members(self):
    if not hasattr(self, '_user_reverse_field_name'):
        self._get_user_reverse_field_name()
    return getattr(self, self._user_reverse_field_name)

```