I have the following tags and message objects in many ways. What I am trying to return in the mail serializer is to return the tags in the list (using only Tag.name only) instead of json, what is the clean way to do this?
serializers.py
class TagSerializer(serializers.ModelSerializer):
class Meta:
model = Tag
fields = ('name', 'description', 'date_created', 'created_by')
class PostSerializer(serializers.ModelSerializer):
tags = TagSerializer(read_only=True, many=True)
class Meta:
model = Post
fields = ('post_id',
'post_link',
'tags')
Currently, PostSerializer returns tags in json format with all fields, I just want it to return tags: ['tag1', 'tag2', 'tag3'] in the list of strings.
source
share