-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested writable serializers validation in ModelSerializer.update method seems wrong #2194
Labels
Milestone
Comments
Okay, didn't consider the case of making a change to |
I'm just lazy and wanted to avoid having to write my own update code. Sorry! |
tomchristie
added a commit
that referenced
this issue
Dec 3, 2014
It's a valid report :) the style in the reference pull request may be less brittle in any case? |
Looks good! |
This was referenced Mar 9, 2017
This was referenced Oct 16, 2017
This was referenced Nov 6, 2017
This was referenced Dec 10, 2017
This was referenced Dec 20, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
update
method onModelSerializer
makes sure that the data doesn't contain nested writable fields of theBaseSerializer
variety, as per the documentation. However, it doesn't actually assert this by looking at the passedvalidated_attrs
. Instead, it does this by looking atself.fields
:This means that even if we pop() the data of the nested serializer (as shown in the changelog example), the assertion still fails. This makes it necessary to call explicitly delete the field from
self.fields
:By the time it gets to
update
, the data has already been validated. So you should be able to assume that any fields not present can be ignored, no?In short, I'd say that it shouldn't trigger the error if the field isn't in the
validated_attrs
.The text was updated successfully, but these errors were encountered: