class User(models.Model):
...
group = models.ManyToManyField(
Group, related_name="users_group", verbose_name="The User Group"
)
class Group(models.Model):
....
User
)class GroupSerializer(serializers.ModelSerializer):
empty = serializers.SerializerMethodField()
class Meta:
...
def get_empty(self, obj):
return not User.objects.filter(group=obj).exists()