Opened 14 years ago
Closed 14 years ago
#13770 closed Bug (fixed)
form BooleanField should clean the string u'false' as False.
Reported by: | jordanb | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | dmclain | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I ran into this trying to assign a JavaScript Boolean false to a HiddenInput widget in a BooleanField. The browser submitted that as u'false', which is cleaned to True by the BooleanField because it only recognizes u"False" or u"0" as valid string-forms of false.
The supplied patch changes the comparison to be case insensitive, so "False", "FALSE", "false", "FaLsE" all work, which is the sensible way to handle it I think.
Note that the patch is for version 1.1 but the behavior exists in SVN as well, with the only difference being line numbers.
Attachments (2)
Change History (10)
by , 14 years ago
Attachment: | case_insensitive_boolean.patch added |
---|
comment:1 by , 14 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
I think this feature makes sense. However, we still need tests for this.
comment:2 by , 14 years ago
Has patch: | unset |
---|---|
Needs tests: | unset |
Version: | 1.1 → 1.2 |
similar problem found in 1.2.3. BooleanField is returned by browser as u'false' but cleaned data shows value as type bool with false value what is absolutely incorrect.
comment:3 by , 14 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Version: | 1.2 → 1.1 |
This behavior existed in 1.1 already, changing version back to 1.1.
This feature _does_ need tests. The patch should be attached in unidiff format. Marking as such again.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 14 years ago
Easy pickings: | unset |
---|---|
Has patch: | set |
Needs tests: | unset |
Patch needs improvement: | unset |
comment:7 by , 14 years ago
Cc: | added |
---|
Patch for case-insensitive cleaning in boolean field for django 1.1.1