Opened 4 years ago

Closed 4 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: aaugustin
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 ptone 4 years ago.

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by ptone

comment:1 Changed 4 years ago by ptone

  • Component changed from Uncategorized to Forms
  • Has patch set
  • Keywords CheckboxInput added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.3 to SVN

comment:2 Changed 4 years ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:3 Changed 4 years ago by aaugustin

  • Patch needs improvement set
  • Triage Stage changed from Ready for checkin to Accepted

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

comment:4 Changed 4 years ago by aaugustin

  • Owner changed from nobody to aaugustin

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 4 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

In [17132]:

(The changeset message doesn't reference this ticket)

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