1👍
✅
language
is the object you are serializing, hence you return:
class ArticleSerializer(serializers.ModelSerializer):
# …
def get_total_likes(self, language):
return language.articlelikes.count()
Source:stackexchange.com