Django Serializer Display Model Field as Dictionary
<p>I apologize, new to Django. I've been scouring the documentation and haven't been able to find the answer to this. </p>

<p>I have a model "Foo" that has a field "bar", which is a dictionary I store as JSON in a TextField. I want a GET request to display this field as a dictionary, but when I make the request, the dictionary is displayed as a single string in JSON format. </p>

<p>To summarize my code:</p>

<p>models:</p>

<pre><code>class Foo(models.Model):
    bar = models.TextField(blank=True, default="{}")
    def getBar(self):
        return json.loads(bar)
</code></pre>

<p>Serializers:</p>

<pre><code>class FooSerializer(serializers.ModelSerializer):
    class Meta:
        model = Foo
        fields = ("bar")
        read_only_fields = ("bar")
    def create(self, data):
        return Foo.objects.create(**data)
</code></pre>

<p>views:</p>

<pre><code>class FooList(generics.ListAPIView):
    queryset = []
    for foo in Foo.objects.all():
        foo.bar = json.loads(foo.bar)
        # Printing type of foo.bar here gives "type &lt;dict&gt;"
        queryset.append(foo)
    serializer_class = FooSerializer
</code></pre>

<p>Thanks! </p>