#33830: Variable lookup errors are logged rendering 'clearable_file_input.html'
---------------------------------+------------------------------------
     Reporter:  Horst Schneider  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  contrib.admin    |                  Version:  4.0
     Severity:  Normal           |               Resolution:
     Keywords:  admin, template  |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by Horst Schneider):

 Although the problem is similar, the fix must be different here. We can
 not easily supply some default context from the outside here since the
 missing variable is in the `attrs` attribute of the checkbox widget.

 It is guaranteed by the base `Widget` that `attrs` will always be a `dict
 ` instance. But it is **not** guaranteed that the key `disabled` will
 always be present on the `attrs`, so we will mostly find it to be either
 missing or set to `True` (could as well be set to `False`, if the default
 is explicitly stated).

 I guess a proper fix would be something along the lines of

 {{{
 <input
     type="checkbox" name="{{ widget.checkbox_name }}"
     id="{{ widget.checkbox_id }}"
     {% if 'disabled' in widget.attrs and widget.attrs.disabled %}
 disabled{% endif %}
 >
 }}}

 (First checking if key is present, then checking its truthiness).

 Or is there a more idiomatic way to perform those checks?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33830#comment:3>
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/01070181d7c5bbac-7427a0f2-c46a-4562-91de-d867829e20a4-000000%40eu-central-1.amazonses.com.

Reply via email to