[Django] #34335: Spurious error when using label_tag of CheckboxSelectMultiple widget

4 views
Skip to first unread message

Django

unread,
Feb 13, 2023, 1:53:08 AM2/13/23
to django-...@googlegroups.com
#34335: Spurious error when using label_tag of CheckboxSelectMultiple widget
---------------------------------------+------------------------
Reporter: krawthekrow | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: dev
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 the `label_tag` method of BoundField, if `attrs == None` and
`id_for_label == ""` (as is possible with
CheckboxSelectMultiple/RadioSelect), it is possible for the attrs passed
into the context to be None. `attrs.items` is used directly in the
`attrs.html` template without checking if `attrs` exists, resulting in the
error `django.template.base.VariableDoesNotExist: Failed lookup for key
[items] in None`.

This would be easily fixed by either passing `attrs or {}` into the
context in the `label_tag` method, or adding an `if attrs` guard in
`attrs.html`.

I have checked that this issue still exists on the main branch.

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

Django

unread,
Feb 13, 2023, 2:39:03 AM2/13/23
to django-...@googlegroups.com
#34335: Spurious error when using label_tag of CheckboxSelectMultiple widget
----------------------------+--------------------------------------
Reporter: Mark Theng | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

Thanks for this report, however many templates, including some of the
Django's templates, rely upon the silence of the template system when a
nonexistent variable is encountered. I don't think it's worth tracking and
changing them (see also #28526).

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

Reply all
Reply to author
Forward
0 new messages