class ChoiceField(**kwargs) [source]
- Default widget:
Select - Empty value:
''(an empty string) - Normalizes to: A Unicode object.
- Validates that the given value exists in the list of choices.
- Error message keys:
required,invalid_choice
The invalid_choice error message may contain %(value)s, which will be replaced with the selected choice.
Takes one extra required argument:
-
choices -
Either an iterable (e.g., a list or tuple) of 2-tuples to use as choices for this field, or a callable that returns such an iterable. This argument accepts the same formats as the
choicesargument to a model field. See the model field reference documentation on choices for more details. If the argument is a callable, it is evaluated each time the field’s form is initialized.
Please login to continue.