Let's say I have a class
class Tags(object):
tags = []
def __init__(self, tags):
self.tags = tags
and a custom list field
class TagsField(serializers.WritableField):
"""
Returns a list of tags, or serializes a list of tags
"""
I am not too sure where to go from here. How can I make sure that a blog post serializer defined as
class BlogPostSerializer(serializers.Serializer):
post = CharField()
tags = TagsField
would give me a json object similar to
{
"post": "Here is my blog post about python",
"tags": ["python", "django", "rest"]
}