I am having struggle with understanding ListField
and DictField
. I want to use it as a field on a serializer. I have a ListField
which
I think instead of doing that, you should use nested serializers.
Create a BusSerializer
having fields idn
and stops_left
. Then include this serializer in your StopOncomingSerializer
as buses
field with many=True
argument to handle multiple buses
data.
class BusSerializer(serializers.Serializer):
idn = serializers.IntegerField(read_only=True)
stops_left = serializers.IntegerField(read_only=True)
class StopOncomingSerialier(serializers.Serializer):
idn = serializers.IntegerField(read_only=True)
buses = BusSerializer(many=True)