#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070186498c661f-791790ca-7449-4d50-b17e-217a5430ac9e-000000%40eu-central-1.amazonses.com.

Reply via email to