Update fields.md explaining how the source argument affects .validated_data - #10008
Open
Ernest0x wants to merge 1 commit into
Open
Update fields.md explaining how the source argument affects .validated_data#10008Ernest0x wants to merge 1 commit into
source argument affects .validated_data#10008Ernest0x wants to merge 1 commit into
Conversation
…re of `.validated_data` One may think that, after successful validation, a key in the `.validated_data` attribute of a serializer always equals the corresponding field name in the serializer. However, that may not be the case if the field has been defined in the serializer with a dotted path value in its `source` argument. In that case, what is actually included in `.validated_data` is a nested dictionary that is derived by expanding the dotted path of the `source` argument. This addition in the documentation clarifies the situation and explains why DRF follows that behavior.
|
I had the same misunderstanding and had to turn to the source code to make that functionality clear. That part of the documentation should not be missing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One may think that, after successful validation, a key in the
.validated_dataattribute of a serializer always equals the corresponding field name in the serializer. However, that may not be the case if the field has been defined in the serializer with a dotted path value in itssourceargument. In that case, what is actually included in.validated_datais a nested dictionary that is derived by expanding the dotted path of thesourceargument. This addition in the documentation clarifies the situation and explains why DRF follows that behavior.