I want to serialize a QuerySet into a JSON object instead of JSON array.
For model Day, the serialized QuerySet should be an object with Day.date keys and serialized Days as values.
class DaySerializer(serializers.ModelSerializer):
class Meta:
model = Day
exclude = []
This returns an array of serialized objects:
DaySerializer(Day.objects.all(),many=True).data
{'15.02.2005':{...},
'16.02.2005':{...},
...
}
I'm curious if there is some DRF way to do that.