[Django] #26813: ModelForm RadioSelect widget for foreign keys should not present a blank option if blank=False on the model

42 views
Skip to first unread message

Django

unread,
Jun 28, 2016, 6:46:33 PM6/28/16
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------+-----------------------------------
Reporter: AlexFromOmaha | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Keywords: modelform radiowidget
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------------------
Unlike the select widget, where a blank option is idiomatic even for
required fields, radioselect has an inherent unfilled state that makes the
"-------" option look suspiciously like a valid choice.


{{{
class TestRun(models.Model):
data_file = models.ForeignKey(BatchData, on_delete=models.SET_NULL,
null=True, blank=False)

class TestRunForm(ModelForm):
class Meta:
model = TestRun
fields = ['data_file']
widgets = {'data_file': RadioSelect()}
}}}

renders {{test_run_form.data_file}} as

{{{
<ul id="id_data_file">
<li><label for="id_data_file_0">
<input checked="checked" id="id_data_file_0" name="data_file"
type="radio" value=""> ---------
</label></li>
<li><label for="id_data_file_1">
<input id="id_data_file_1" name="data_file" type="radio" value="1">
First Data File
</label></li>
</ul>
}}}

Instead, there should be no checked option for RadioSelect's <input> tags
when rendering a new form from a model if blank is not a valid selection.

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

Django

unread,
Jun 28, 2016, 9:36:50 PM6/28/16
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------

Reporter: AlexFromOmaha | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Aug 22, 2016, 7:58:47 AM8/22/16
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: AlexFromOmaha | Owner: er3do
Type: Bug | Status: assigned
Component: Forms | Version: 1.9

Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by er3do):

* owner: nobody => er3do
* status: new => assigned


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

Django

unread,
Apr 13, 2019, 12:17:07 PM4/13/19
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Dmitry
| Homenok
Type: Bug | Status: assigned
Component: Forms | Version: 1.9

Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ludwig Kjellström):

A pull request is available here:
https://github.com/django/django/pull/11199

--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:3>

Django

unread,
Apr 13, 2019, 12:37:57 PM4/13/19
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Dmitry
| Homenok
Type: Bug | Status: assigned
Component: Forms | Version: master

Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1
* version: 1.9 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:4>

Django

unread,
Jun 6, 2019, 6:34:32 AM6/6/19
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Ludwig
| Kjellström

Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => assigned
* owner: nobody => Ludwig Kjellström


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:5>

Django

unread,
Jun 6, 2019, 7:20:02 AM6/6/19
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Ludwig
| Kjellström
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:6>

Django

unread,
Feb 2, 2020, 12:05:59 PM2/2/20
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Hasan
| Ramezani

Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: Ludwig Kjellström => Hasan Ramezani
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:7>

Django

unread,
Feb 4, 2020, 7:44:02 AM2/4/20
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:8>

Django

unread,
Feb 4, 2020, 10:45:13 AM2/4/20
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:9>

Django

unread,
Feb 5, 2020, 4:49:07 AM2/5/20
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"1d5fb35e6a23c0670f3a128802a1776c8c7deaa8" 1d5fb35]:
{{{
#!CommitTicketReference repository=""
revision="1d5fb35e6a23c0670f3a128802a1776c8c7deaa8"
Refs #26813 -- Added test for ModelChoiceField.choices when using
RadioSelect widget.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:10>

Django

unread,
Feb 5, 2020, 4:49:08 AM2/5/20
to django-...@googlegroups.com
#26813: ModelForm RadioSelect widget for foreign keys should not present a blank
option if blank=False on the model
-------------------------------------+-------------------------------------
Reporter: Alex Heyden | Owner: Hasan
| Ramezani
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed

Keywords: modelform | Triage Stage: Accepted
radiowidget |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"da79ee472d803963dc3ea81ee67767dc06068aac" da79ee47]:
{{{
#!CommitTicketReference repository=""
revision="da79ee472d803963dc3ea81ee67767dc06068aac"
Fixed #26813 -- Prevented empty choice in ModelChoiceField with
RadioSelect for fields with blank=False.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:11>

Reply all
Reply to author
Forward
0 new messages