def get_queryset(self):
        queryset = self.request.user.messages_to_moderate
        # Filter by group if group is in kwargs
        group = self.kwargs.get('group')
        if group:
            queryset = queryset.filter(thread__group_id=group)

        queryset = queryset.select_related(
            'thread', 'thread__group', 'thread__group__group', 'sender')

        return queryset
Change the groups to which a user belongs
dataset/ETHPy150Open ofa/connect/open_connect/moderation/views.py/ModeratorView.get_queryset--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/solaris_user.py/chgroups