Propagate 'default' from model_field to serializer field#8002
Closed
john-parton wants to merge 1 commit intoencode:masterfrom
Closed
Propagate 'default' from model_field to serializer field#8002john-parton wants to merge 1 commit intoencode:masterfrom
john-parton wants to merge 1 commit intoencode:masterfrom
Conversation
This was referenced May 21, 2021
|
@john-parton I have been trawling through the DRF documentation trying to work out how to use the It appears that this is not actually possible (until this PR is merged)? I would have assumed that this was a natural and reasonable feature to expect! +1 to getting this feature merged it this is not already the case. |
This was referenced Jun 21, 2021
Closed
29 tasks
Contributor
|
Thanks, @john-parton, I just really wanted this too! There were are a few test failures here that I'm going to clean up and resubmit as a new PR. |
Contributor
|
Submitted as #8130. |
Contributor
Author
|
Superseded by #8130 |
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.
Description
This is an attempt to fix #7469
It's actually really simple.
ModelSerializer.build_standard_fieldlooks for thedefaultkey in the dictionary returned byget_field_kwargs, butget_field_kwargsnever returns a dictionary with that key.Edit
I was personally motivated to fix this because I wanted the
defaultvalue to appear when you do anOPTIONSquery. That's incredibly tedious without this fix. More info here: #8003