Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27759 closed Bug (fixed)

Template widget rendering: attrs with value False now render

Reported by: Jon Dufresne Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: 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

In Django 1.10, widget attrs with a value of False do not render. See the code: https://github.com/django/django/blob/stable/1.10.x/django/forms/utils.py#L40-L42

In Django 1.11, these attributes now render as ="False". This is because the attrs.html template only looks for the boolean value True.

This forces code of the form:

attrs['readonly'] = some_bool_condition()

To:

if some_bool_condition():
    attrs['readonly'] = True

Change History (5)

comment:1 by Jon Dufresne, 8 years ago

Has patch: set
Needs tests: set

comment:2 by Jon Dufresne, 8 years ago

Needs tests: unset

Added test.

comment:3 by Tim Graham, 8 years ago

Triage Stage: UnreviewedReady for checkin

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 5fa390e:

Fixed #27759 -- Prevented forms attrs.html template from rendering False attrs.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01.

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 9e9d0f8:

[1.11.x] Fixed #27759 -- Prevented forms attrs.html template from rendering False attrs.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01.

Backport of 5fa390ee81c5a963fc4476e8de6c1e5e1fc57e22 from master

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