#31820: CheckboxSelectMultiple widget doesn't work with TextChoices enabled
CharFields
--------------------------------------+------------------------
Reporter: Remy | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------+------------------------
# forms.py
{{{
class MovieForm(forms.ModelForm):
class Meta:
model = Movie
fields = [
'genres',
]
widgets = {
'genres': forms.CheckboxSelectMultiple
}
}}}
# models.py
{{{
class Movie(models.Model):
class Genre(models.TextChoices):
SCIFI = 'S', 'Science Fiction'
ACTION = 'A', 'Action'
genres = models.charField(max_length=1, choices=Genre.choices)
}}}
# template
{{{
{{ form.genres.errors }}
}}}
Select one checkbox for example, then post the form. On `form.save()`, the
following error is returned to the template:
{{{
"Select a valid choice. ['S'] is not one of the available choices."
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31820>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.3f13afe59b9d058dd60ecca70c562f0d%40djangoproject.com.