-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Allow run_validators() to handle non-dict types. #6365
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
Conversation
Fixes encode#6053. Original test case thanks to Vincent Delaitre in encode#6242.
6a7ba11
to
1dfd4d6
Compare
Huffs grumpily OKAY FINE Seriously tho, yeah cool. Probably makes sense given the feedback on that ticket. Thanks fella. |
Fixes encode#6053. Original test case thanks to Vincent Delaitre in encode#6242.
@carltongibson Can you remind, why we only for dict use not the origin object but copy created by adding data to read only defaults? django-rest-framework/rest_framework/serializers.py Lines 468 to 477 in f113ab6
|
@kai-nashi When a field has a default value, it needs to be part of the serialiser data, even when otherwise read-only. django-rest-framework/tests/test_validators.py Lines 299 to 321 in f113ab6
|
Fixes #6053.
to_internal_value()
is expected to return a dict. #5922 relied on this, but users are implementing custom serialisers that return application objects[*]. This PR bypasses the read-only defaults handling for non-dict objects.[*]: This is why static typing will never work for Python 😀
Original test case thanks to @vdel in #6242.