#32434 closed Bug (wontfix)
Using a RadioSelect widget with ModelChoiceField results in no empty option
Reported by: | Matthew Rowbottom | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 3.1 |
Severity: | Normal | Keywords: | modelchoicefield radioselect |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
Prior to Django v3.1, both of the fields in the following form would be rendered with an empty option, labelled as '---------':
from django import forms from .models import Animal class AnimalForm(forms.Form): animal_select = forms.ModelChoiceField( queryset=Animal.objects.all(), required=False, ) animal_radio = forms.ModelChoiceField( queryset=Animal.objects.all(), required=False, widget=forms.RadioSelect() )
Since Django v3.1, the field using the RadioSelect widget no longer displays the empty option.
I've tested it with the following versions:
3.0 works
3.0.12 works
3.1 broken
3.1.6 broken
3.2a1 broken
I can't find anything in the docs or the v3.1 release notes (https://docs.djangoproject.com/en/dev/releases/3.1/#forms) to explain the change.
Attachments (1)
Change History (3)
by , 4 years ago
Attachment: | Screen Shot 2021-02-06 at 2.25.47 pm.png added |
---|
comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
An empty option for RadioSelect()
without blank=True
in Django < 3.1 was a bug (see #26813 and da79ee472d803963dc3ea81ee67767dc06068aac). That's why release notes are not included. You can add blank=True
to restore an empty option.
comment:2 by , 4 years ago
Resolution: | invalid → wontfix |
---|
Example of how the fileds are rendered