List field input in django rest frameowrk browsable api - mongoengine
<p>I have created a <code>serializer</code> that takes a list argument <code>tags</code>, but on the <code>django-rest-framework</code> browsable api, It doesn't seem to work.</p>

<p>Code:</p>

<p><strong>Model</strong></p>

<pre class="lang-py prettyprint-override"><code>class SocialFeed(Document):
    platform = StringField(max_length=20, required=True, choices=('facebook', 'twitter', 'instagram'))
    tags = ListField(default=None)
    created_at = DateTimeField(default=datetime.now(), required=True)
</code></pre>

<p><strong>Serializer</strong></p>

<pre class="lang-py prettyprint-override"><code>class SocialFeedCreateSerializer(DocumentSerializer):
    class Meta:
        model = SocialFeed
        fields = [
            'id',
            'platform',
            'tags'
        ]
</code></pre>

<p><strong>View</strong></p>

<pre class="lang-py prettyprint-override"><code>class SocialFeedCreateAPIView(CreateAPIView):
    queryset = SocialFeed.objects.all()
    serializer_class = SocialFeedCreateSerializer
</code></pre>

<p>But on the browsable <code>API</code>, It shows a simple input box to enter tags, and I don't know what format should I put the tags in on the browsable <code>API</code> side, and I am not receiving list of tags instead a string.</p>

<p>I have tried following inputs:</p>

<pre><code>#1 - ['social media', 'digital media', 'digital']
#2 - 'social media', 'digital media', 'digital'
#3 -  social media, digital media, digital
#4 - "social media", "digital media", "digital"
</code></pre>

<p>But on the <code>MongoDb</code>, when I fetch the document, It shows string instead a list of tags, like this:</p>

<pre class="lang-py prettyprint-override"><code>"tags" : [
    "['social media','digital media','digital']"
]

"tags" : [
    "'social media','digital media','digital'"
]

"tags" : [
    "social media, digital media, digital]"
]

"tags" : [
    "\"social media\", \"digital media\", \"digital\""
]
</code></pre>

<p><strong>Required Output</strong></p>

<pre class="lang-py prettyprint-override"><code>"tags" : [
    "social media",
    "digital media",
    'digital"
]
</code></pre>

<p>If anybody has faced the same issue, please guide me.</p>

<p>DRF does only support Django's fields. You likely need to make some fields more explicits in the serializer's declaration, like making <code>tags</code> inherit from a <code>serializer.ListField</code>.</p>

python django django-rest-framework mongoengine browsable