[Django] #27759: Template widget rendering: attrs with value False now render

5 views
Skip to first unread message

Django

unread,
Jan 22, 2017, 1:18:55 PM1/22/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
----------------------------------------+------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
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
[https://github.com/django/django/blob/12cefee5d84b3569ccbde03167c7853e8dac638f/django/forms/templates/django/forms/widgets/attrs.html
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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27759>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 22, 2017, 1:34:32 PM1/22/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
------------------------------+--------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jon Dufresne):

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/7925 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27759#comment:1>

Django

unread,
Jan 22, 2017, 2:21:49 PM1/22/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
------------------------------+--------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jon Dufresne):

* needs_tests: 1 => 0


Comment:

Added test.

--
Ticket URL: <https://code.djangoproject.com/ticket/27759#comment:2>

Django

unread,
Jan 23, 2017, 8:46:32 AM1/23/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27759#comment:3>

Django

unread,
Jan 23, 2017, 9:28:32 AM1/23/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.11
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"5fa390ee81c5a963fc4476e8de6c1e5e1fc57e22" 5fa390e]:
{{{
#!CommitTicketReference repository=""
revision="5fa390ee81c5a963fc4476e8de6c1e5e1fc57e22"
Fixed #27759 -- Prevented forms attrs.html template from rendering False
attrs.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27759#comment:4>

Django

unread,
Jan 23, 2017, 1:15:15 PM1/23/17
to django-...@googlegroups.com
#27759: Template widget rendering: attrs with value False now render
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"9e9d0f8ef7577f2369cb91115d159c950ad81e3e" 9e9d0f8]:
{{{
#!CommitTicketReference repository=""
revision="9e9d0f8ef7577f2369cb91115d159c950ad81e3e"
[1.11.x] Fixed #27759 -- Prevented forms attrs.html template from
rendering False attrs.

Regression in b52c73008a9d67e9ddbb841872dc15cdd3d6ee01.

Backport of 5fa390ee81c5a963fc4476e8de6c1e5e1fc57e22 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27759#comment:5>

Reply all
Reply to author
Forward
0 new messages