'add a single data to serializer in django
I'm writing an API where the user's followers are listed.I also want to send the total number of followers in this API.But the totalFollower field keeps repeating.I only want it sent once. Like that:
[
totalFollower:2
followers:
{
{
"following": "gizli_takip",
},
{
"following": "herkeseacikvetakip",
}
}]
MY serializer
class SerializerUserFollowings(serializers.ModelSerializer):
following = serializers.CharField(source="follower.username")
totalFollower = serializers.ReadOnlyField()
class Meta:
model = ModelFollower
fields = ("following","totalFollower")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

