Opened 17 years ago
Closed 15 years ago
#6937 closed (fixed)
newforms BooleanField should be more tolerant of different inputs
Reported by: | Simon Willison | Owned by: | Andrew Gibson |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Here's how BooleanField works at the moment:
http://code.djangoproject.com/browser/django/trunk/django/newforms/fields.py#L534
if value == 'False': return False return bool(value)
It would be really nice if it had a slightly more human-friendly idea of what constituted true and false values. For example, '1' v.s. '0', 'true' v.s. 'false', 'yes' v.s. 'no' etc. At the moment it assumes it will only be called from a check box widget, but there are times when this code will be used for input that didn't come from an HTML form.
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 16 years ago
(of course, that was a naive prototype, you should check that value is a string too)
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 16 years ago
Has patch: | set |
---|
My first attempt at submitting a patch. I know it's not a big deal, was just trying to learn the process. Hope it helps:)
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This is actually a dupe ticket - it was fixed somewhere along the way (for '0' at least)
Easy to implement, just need a call from core whether we want to do this...