Nested serializer source argument fails silently: field missing #9536
Unanswered
dennisvang
asked this question in
Potential Issue
Replies: 1 comment 1 reply
-
https://github.com/encode/django-rest-framework/blob/master/rest_framework/fields.py#L431 I had to remind myself from the source what's going on here. Looks like you'll get an error if the field is required otherwise it'll be omitted. I'd suggest this neither is nor isn't a bug, it's just fuzzy behavior. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This looks like a bug, but maybe there's some documentation that I missed.
Suppose I have a model serializer with a field based on a nested serializer:
Normally this works.
However, there are (afaik) two cases in which
my_field
is completely omitted from the serialized data:source
argument (e.g. I erroneously tried to use django lookup syntax:'foo__bar_set'
)foo
object, i.e. ifMyModel.foo
isNone
There is no error to warn about the missing field.
Using DRF 3.15.2 on windows 10 or linux, python 3.11.
Also see here.
Beta Was this translation helpful? Give feedback.
All reactions