#29921: Default BooleanField.required different from Django 2.0 when using
choices
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
bogdanbatog |
Type: | Status: new
Uncategorized |
Component: Forms | Version: 2.1
Severity: Normal | Keywords: BooleanField,
Triage Stage: | widget, required
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Using a BooleanField with choices inside a ModelForm, without explicit
blank or null attributes on the model, exhibits different defaults for
required attribute on the widget in Django2.1 vs Django2.0.
The code below prints True in Django2.1.2 and False in Django2.0.6
{{{
class XModel(models.Model):
result_bool = models.BooleanField(
choices=(
(True, 'Positive'),
(False, 'Negative'),
),
default=False
)
class XForm(forms.ModelForm):
class Meta:
model = XModel
fields = ['result_bool']
XForm(XModel()).fields['result_bool'].required
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29921>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.7c0cd1242c211f6d8c818e3700973496%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.