#10549 closed (fixed)
BooleanField.formfield() does not handle choices correct. [PATCH]
Reported by: | Sebastian Noack | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you have a BooleanField, with choices (as in the example below), the formfield() method always returns a TypedChoicesField, with a blank choice at the beginning. This is because of this entry is included always if the blank is True and BooleanFields are always blank=True. So we have to check for null instead of blank, when using BooleanFields, since the blank flag in the BooleanfField does not specify if the field can be empty in forms in contrast to other fields.
FLAG_CHOICES = ( (0, _('No'), (1, _('Yes'), ) class Foo(models.Model): flag = models.BooleanField(choices=FLAG_CHOICES)
Attachments (1)
Change History (6)
by , 16 years ago
Attachment: | fixed-choices-handling-of-BooleanFields.patch added |
---|
comment:1 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
comment:3 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 16 years ago
I must say, it is rather amusing how this tests for something which you can't actually do, due to r10456
See also #9640