[Django] #32434: Using a RadioSelect widget with ModelChoiceField results in no empty option

19 views
Skip to first unread message

Django

unread,
Feb 9, 2021, 11:05:37 PM2/9/21
to django-...@googlegroups.com
#32434: Using a RadioSelect widget with ModelChoiceField results in no empty option
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Rowbottom |
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Normal | Keywords: modelchoicefield
Triage Stage: | radioselect
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Prior to Django v3.1, both of the fields in the following form would be
rendered with an empty option, labelled as '---------':

{{{#!python
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32434>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 9, 2021, 11:06:55 PM2/9/21
to django-...@googlegroups.com
#32434: Using a RadioSelect widget with ModelChoiceField results in no empty option
-------------------------------------+-------------------------------------
Reporter: Matthew Rowbottom | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Normal | Resolution:

Keywords: modelchoicefield | Triage Stage:
radioselect | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Matthew Rowbottom):

* Attachment "Screen Shot 2021-02-06 at 2.25.47 pm.png" added.

Example of how the fileds are rendered

Django

unread,
Feb 10, 2021, 12:56:53 AM2/10/21
to django-...@googlegroups.com
#32434: Using a RadioSelect widget with ModelChoiceField results in no empty option
-------------------------------------+-------------------------------------
Reporter: Matthew Rowbottom | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1
Severity: Normal | Resolution: invalid

Keywords: modelchoicefield | Triage Stage:
radioselect | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32434#comment:1>

Django

unread,
Feb 10, 2021, 12:58:47 AM2/10/21
to django-...@googlegroups.com
#32434: Using a RadioSelect widget with ModelChoiceField results in no empty option
-------------------------------------+-------------------------------------
Reporter: Matthew Rowbottom | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1
Severity: Normal | Resolution: wontfix

Keywords: modelchoicefield | Triage Stage:
radioselect | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: invalid => wontfix


--
Ticket URL: <https://code.djangoproject.com/ticket/32434#comment:2>

Reply all
Reply to author
Forward
0 new messages