Django REST Framework And Combining Models
Updated question I was able to get it to work and have updated the codes below. But now my question is how can the fields in iceinfo be edited? As it stands now it is returned as I
Solution 1:
Assuming your goal is to serializers many instances of IceInfo, what is the purpose of IceList? Or are you trying something different? Rest framework has no problem serialising multiple objects into a list.
You can do that by passing the queryset to the serializer, and give give the keyword many=True. See here: documentation
The result would be something like
queryset = IceInfoSerializer(IceInfo.objects.all(), many=True)
.
About the new question, you should be able to edit them from the queryset. What have you tried so far? (You may be better of opening a new topic on the new question)
Also, the JSON you posted doesn't seem valid, can you check if you copy pasted it correctly?
Post a Comment for "Django REST Framework And Combining Models"