Closed peeomid closed 6 years ago
This is expected behaviour.
Base field-level validation is applied before the additional serialiser-level methods are called.
Your best bet is to subclass the field and override to_internal_value
to make the lower()
call.
Thanks a lot for such quick response @carltongibson, and thanks for pointing out the suggestion.
Just curious about this design though, as I thought serializer would be wrapper on top, before executing model level thing?
Checklist
master
branch of Django REST framework.Steps to reproduce
I have a model with choice field (this is from fcm-django)
And in its serializer, I try to convert type to lower case
Expected behavior
So when I pass value "IOS", it should convert to "ios" before validating with choices.
Actual behavior
It actually raises validation error before being validated