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
Injection of read-only default values is done too late #6242
Conversation
Why the close? |
I realized things were more intricated than what I initially thought and I'm not sure to have the time to dig this deeper. Here is my current understanding of the problem:
So I have the impression we are a bit stuck in a design issue here:
How do you see things? One solution could maybe be to rename |
This works but would break the compatibility for everyone who overrides I won't have the time to dig deeper than that, hope this helps ! |
Thanks. I'm sure anyone digging into this will appreciate the legwork you've put into it. |
Fixes encode#6053. Original test case thanks to Vincent Delaitre in encode#6242.
Fixes encode#6053. Original test case thanks to Vincent Delaitre in encode#6242.
Fixes encode#6053. Original test case thanks to Vincent Delaitre in encode#6242.
refs #6053
The
value
returned byto_internal_value
might not be a dictionary. In such cases, when passing the value from this line https://github.com/encode/django-rest-framework/blob/master/rest_framework/serializers.py#L434 torun_validators
just below, it fails to callto_validate.update
becausevalue
is not a dictionary.The proposed fix is to inject the default values before converting the input data to internal value