class UserSerializer(serializers.ModelSerializer):
    groups = GroupSerializer(many=True)


class Meta:
    model = User
fields = 'url', 'username', 'email', 'is_staff', 'groups'
How to serialize groups of a user with Django-Rest-Framework