{{{
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.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:1>
* owner: nobody => er3do
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:2>
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>
* has_patch: 0 => 1
* version: 1.9 => master
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:4>
* status: new => assigned
* owner: nobody => Ludwig Kjellström
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:5>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:6>
* 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>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26813#comment:9>
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>
* 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>