[Django] #31536: Disabled clearable file field widget is not disabling the checkbox

61 views
Skip to first unread message

Django

unread,
May 4, 2020, 11:34:43 AM5/4/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles | Owner: nobody
Pina Estany |
Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Keywords: form, filefield,
Triage Stage: | clearable_file_input
Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Using a forms.FileField with a disabled widget is disabling the "Browse"
button but not the checkbox to "Clear" the file.

Checking the checkbox and submitting cause no effect since the widget is
disabled but the UI is confusing.

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

Django

unread,
May 4, 2020, 11:40:40 AM5/4/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:

Keywords: form, filefield, | Triage Stage:
clearable_file_input | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carles Pina Estany):

* Attachment "31536-clearable_file_input_disabled.patch" added.

Possible patch for the described problem

Django

unread,
May 4, 2020, 11:45:56 AM5/4/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:

Keywords: form, filefield, | Triage Stage:
clearable_file_input | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carles Pina Estany):

Possible fix: https://github.com/cpina/django/tree/ticket_31536 (or
attached as a patch)

Let me know if I can do anything else - if a unit test needs to be
improved or added I can have a look, I'm new here and I haven't looked yet
if templates have accompanying unit tests but I thought of sending the
patch for now.

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

Django

unread,
May 4, 2020, 12:58:03 PM5/4/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:

Keywords: form, filefield, | Triage Stage:
clearable_file_input | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carles Pina Estany):

If the fix looked good I'm happy to re-write the commit message to past
tense and with "fixed"

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

Django

unread,
May 5, 2020, 6:54:15 AM5/5/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_tests: 0 => 1
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Hi Carles, seems reasonable yes.

Please assign yourself this issue, open a PR on GitHub, and do include
some tests too. :)

There are related tests here:
`django/tests/forms_tests/widget_tests/test_clearablefileinput.py`

Thanks!

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

Django

unread,
May 5, 2020, 7:01:09 AM5/5/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
Type: | Pina Estany
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carles Pina Estany):

* owner: nobody => Carles Pina Estany
* status: new => assigned


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

Django

unread,
May 5, 2020, 12:02:50 PM5/5/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
Type: | Pina Estany
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by David Smith):

* cc: David Smith (added)


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

Django

unread,
May 5, 2020, 4:51:50 PM5/5/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
Type: | Pina Estany
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carles Pina Estany):

Hi Carlton,

Replying to [comment:3 Carlton Gibson]:


> Hi Carles, seems reasonable yes.
>
> Please assign yourself this issue, open a PR on GitHub, and do include
some tests too. :)

Done here:
https://github.com/django/django/pull/12864


> There are related tests here:
`django/tests/forms_tests/widget_tests/test_clearablefileinput.py`

Thanks for the pointer, done the test there as well (it also tests the
"disabled" on the input field)

Cheers,

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:6>

Django

unread,
May 7, 2020, 3:13:37 AM5/7/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
Type: | Pina Estany
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carles Pina Estany):

* needs_tests: 1 => 0


Comment:

Unticked "Needs tests": tests are now in the PR

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:7>

Django

unread,
May 11, 2020, 8:40:06 AM5/11/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
Type: | Pina Estany
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Accepted
clearable_file_input |

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Carles Pina Estany):

Adding PR link to find it easier:
https://github.com/django/django/pull/12864

Thanks,

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:8>

Django

unread,
Jun 1, 2020, 6:22:32 AM6/1/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
| Pina Estany
Type: Bug | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: form, filefield, | Triage Stage: Ready for
clearable_file_input | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by felixxm):

* type: Cleanup/optimization => Bug
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:9>

Django

unread,
Jun 1, 2020, 6:48:21 AM6/1/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
| Pina Estany
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: form, filefield, | Triage Stage: Ready for
clearable_file_input | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"e46c2326c8cfc038e015f55fd050ab5d7eb91b62" e46c2326]:
{{{
#!CommitTicketReference repository=""
revision="e46c2326c8cfc038e015f55fd050ab5d7eb91b62"
Fixed #31536 -- Fixed rendering of disabled AdminFileWidget and
ClearableFileInput.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:10>

Django

unread,
Jun 1, 2020, 6:48:55 AM6/1/20
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
| Pina Estany
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: form, filefield, | Triage Stage: Ready for
clearable_file_input | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"56af541790a7acf23fe5c911a4e04969ddac1dc6" 56af541]:
{{{
#!CommitTicketReference repository=""
revision="56af541790a7acf23fe5c911a4e04969ddac1dc6"
[3.1.x] Fixed #31536 -- Fixed rendering of disabled AdminFileWidget and
ClearableFileInput.

Backport of e46c2326c8cfc038e015f55fd050ab5d7eb91b62 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:11>

Django

unread,
Jul 6, 2022, 4:24:38 AM7/6/22
to django-...@googlegroups.com
#31536: Disabled clearable file field widget is not disabling the checkbox
-------------------------------------+-------------------------------------
Reporter: Carles Pina Estany | Owner: Carles
| Pina Estany
Type: Bug | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: fixed
Keywords: form, filefield, | Triage Stage: Ready for
clearable_file_input | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by suspectpart):

It seems like the fix to this issue raised a problem similar to Ticket
#32681: Not checking whether the `disabled` attribute actually exists on
the `attrs` of the 'clear' checkbox causes a `VariableDoesNotExist`
exception to be logged every time the template is rendered with a checkbox
that has no `disabled` atrribute:

{{{
[2022-07-06 10:06:03,452] DEBUG django.template base: Exception while
resolving variable 'disabled' in template
'admin/widgets/clearable_file_input.html'.
Traceback (most recent call last):
File "/home/horst/some_project/venv/lib/python3.10/site-
packages/django/template/base.py", line 875, in _resolve_lookup
current = current[bit]
KeyError: 'disabled'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/horst/some_project/venv/lib/python3.10/site-
packages/django/template/base.py", line 885, in _resolve_lookup
current = getattr(current, bit)
AttributeError: 'dict' object has no attribute 'disabled'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/horst/some_project/venv/lib/python3.10/site-
packages/django/template/base.py", line 891, in _resolve_lookup
current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'disabled'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/horst/some_project/venv/lib/python3.10/site-
packages/django/template/base.py", line 898, in _resolve_lookup
raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key
[disabled] in {'id': 'id_document'}
}}}

Should this be a new ticket?

--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:12>

Reply all
Reply to author
Forward
0 new messages