Writable nested serializer with 'source' argument #9191
Unanswered
pwellever
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am encountering an issue implementing writable serializers with nested relationships. Below is a simplified example:
Notice that on
ParentSerializer
, the field name isoffspring
, whereas the name of the reverse relation on theParent
model ischildren
. The serializer field uses thesource=
argument to address this. And indeed,ParentSerializer
behaves as expected when used to display existing data.However, when attempting to save a new instance...
The
validated_data
dict has altered the field name fromoffspring
tochildren
. Shouldn't this be respecting the field name declared on the serializer instead of conforming it to the model definition? This behavior does not seem to happen with "normal" serializer fields that use thesource
argument -- it's only appearing when the serializer field is another (nested) serializer.Is this the intended behavior?
Beta Was this translation helpful? Give feedback.
All reactions