[Answered ]-Django Nested Serializer Field – Empty OrderedDict

1👍

It’s because the ‘id’ field in OrganizationSerializer is read_only, you can check it yourself in python manage.py shell

test = OrganizationSerializer()
print(repr(test))

0👍

Using tempresdisk’s method above, the serializer should look like this

OrganizationSerializer():
    id = IntegerField(label='ID', read_only=True)  
    ...

Overriding that field in the serializer and removing the read_only=True should do the trick.

class OrganizationSerializer(QueryFieldsMixin, BaseSecuritySerializer):
    id = IntegerField(label='ID')

    class Meta:
        model = Organization
        fields = ("id", "name")
        depth = 0

Leave a comment