Django rest framework, serializing multiple models?

Suppose you have BaseClass and ChildClass1, ChildClass2 with their fields.

I want to give create url endpoint where I can return a list of mixed models with their fields included.

[
 childClass1_obj1,
 childClass2_obj2,
 childClass1_obj3
]

      

I have serializers for every type already configured and it would be helpful to reuse it, but if that isn't possible, I can live with any solution that works.

Returning results from multiple models using the Django REST Framework says similar things, but it only serializes the common part of the two.

+3


source to share





All Articles