In my model I have, for now, 3 classes:
- Quest: Basics attributes of quest
- GoToAndAnswer: Kinda type of a quest, which extends Quest
- SeekAndAnswer: Same as above, extending Quest
I'm using Django to build an API so in my View I want to print the info about these Quests in JSON format. The problem is I don't know how to serialize the objects correctly (Im really new at Django and Python):
# Only get the attributes of the class Quest, obviously
serializers.serialize("json", Quest.objects.all())
# Only get the atributes of the GoToAndAnswer, nothing about the Quest attributes
serializers.serialize("json", GoToAndAnswer.objects.all())
So which is the best way to achieve this?
I have seen posts like this: JSON Serialization of a Django inherited model
But it didnt help...
Thanks in advance