Opened 14 years ago
Closed 14 years ago
#17114 closed Bug (fixed)
Passing a value of int(1) to CheckBox.render doesn't include the value
| Reported by: | Owned by: | Aymeric Augustin | |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | CheckboxInput |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
Specifically the check here: https://github.com/django/django/blob/438c41b4faf99435ca28eaa0ccac3ff40a79600c/django/forms/widgets.py#L481
It's the True part of the list that causes the issue so the equivalent if 1 in not (True,): print 'error' will yield the same result. The effect of this is no value="1" if you pass that into the CheckBox.render() method.
Attachments (1)
Change History (6)
by , 14 years ago
| Attachment: | 17114.diff added |
|---|
comment:1 by , 14 years ago
| Component: | Uncategorized → Forms |
|---|---|
| Has patch: | set |
| Keywords: | CheckboxInput added |
| Triage Stage: | Unreviewed → Accepted |
| Version: | 1.3 → SVN |
comment:2 by , 14 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:3 by , 14 years ago
| Patch needs improvement: | set |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
comment:4 by , 14 years ago
| Owner: | changed from to |
|---|
This is related to #16820.
Django's understanding of which values cause a checkbox to be checked or unchecked doesn't match the HTTP spec (and browsers honor this part of the spec), and this is the problem in both tickets.
The same problem exists for 0, for the same reason:
0 == Falsebut0 is not False.