Opened 5 years ago

Closed 5 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: master
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 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by Preston Holmes

Attachment: 17114.diff added

comment:1 Changed 5 years ago by Preston Holmes

Component: UncategorizedForms
Has patch: set
Keywords: CheckboxInput added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted
Version: 1.3SVN

comment:2 Changed 5 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin

comment:3 Changed 5 years ago by Aymeric Augustin

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 Changed 5 years ago by Aymeric Augustin

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 Changed 5 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

In [17132]:

(The changeset message doesn't reference this ticket)

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