You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to have a polymorphism inside the serializers.ListField. What is an idiomatic way of having a list of A | B values? For example in OpenAPI something like
But in this case MyPolymorphicSerializer should somehow dispatch between two variant serializer classes.
Using SerializerMethodField would also require copying parts of ListSerializer, which will lead to a divergency with DRF updates.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I am trying to have a polymorphism inside the
serializers.ListField
. What is an idiomatic way of having a list ofA | B
values? For example in OpenAPI something likeSo, in the serializer class it should be something like
But in this case
MyPolymorphicSerializer
should somehow dispatch between two variant serializer classes.Using
SerializerMethodField
would also require copying parts ofListSerializer
, which will lead to a divergency with DRF updates.Beta Was this translation helpful? Give feedback.
All reactions