Polymorphic serializers example #9165
Unanswered
unrealsolver
asked this question in
Question & Answer
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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