Skip to content

Model CharFiled with choices attribute mapped to regular Serializer CharField instead of ChoicesField when editable is set to False #8511

Discussion options

You must be logged in to vote

Hi! This is by design. A ChoiceField is a field that can accept a value out of a limited set of choices [1]. If your field is not editable, Django assumes it's not supposed to be set [2], so the field won't show up in the admin or any ModelForm. With DRF and serializers it's the same! Since it's not supposed to be set to any value, it doesn't make sense to use a ChoiceField, because there's no need for validation.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by tomchristie
Comment options

You must be logged in to vote
2 replies
@yyyyyyyan
Comment options

@vakorol
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants