I\'m developing a mobile application backend with Django 1.9.1 I implemented the follower model and now I want to list all of the followers of a user but I\'m currently stuck t
I think what you need is the nested serializer:
class FollowerSerializer(serializers.ModelSerializer):
username = serializers.CharField(source='user__username')
class Meta:
model = UserProfile
fields = ('username', )
class FollowerSerializer(serializers.ModelSerializer):
followers = FollowerSerializer(many=True, read_only=True)
class Meta:
model = UserProfile
fields = ('followers', )