Opened 13 years ago

Closed 13 years ago

#17114 closed Bug (fixed)

Passing a value of int(1) to CheckBox.render doesn't include the value

Reported by: george@… 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)

17114.diff (1.4 KB ) - added by Preston Holmes 13 years ago.

Download all attachments as: .zip

Change History (6)

by Preston Holmes, 13 years ago

Attachment: 17114.diff added

comment:1 by Preston Holmes, 13 years ago

Component: UncategorizedForms
Has patch: set
Keywords: CheckboxInput added
Triage Stage: UnreviewedAccepted
Version: 1.3SVN

comment:2 by Claude Paroz, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Aymeric Augustin, 13 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

The same problem exists for 0, for the same reason: 0 == False but 0 is not False.

comment:4 by Aymeric Augustin, 13 years ago

Owner: changed from nobody to Aymeric Augustin

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.

comment:5 by Aymeric Augustin, 13 years ago

Resolution: fixed
Status: newclosed

In [17132]:

Fixed #17114 -- Handled integer values 0 and 1 for checkboxes like other integer values, not like False and True.

Note: See TracTickets for help on using tickets.
Back to Top