Missing optional RelatedField leads to KeyError when accessing Serializer.data #8931
Unanswered
dtomas
asked this question in
Potential Issue
Replies: 1 comment
-
can you please share code examples and related docs of what you are trying to achieve? |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
When accessing the
.data
property of aSerializer
with an optionalRelatedField
, aKeyError
is raised if the field is missing fromserializer.validated_data
, since the exception is not being caught inRelatedField.get_attribute
.In
Field.get_attribute
however,SkipField
is raised in this case. Shouldn't this be done for optional related fields as well?Beta Was this translation helpful? Give feedback.
All reactions