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.
* Attachment "31536-clearable_file_input_disabled.patch" added.
Possible patch for the described problem
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>
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>
* 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>
* owner: nobody => Carles Pina Estany
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:4>
* cc: David Smith (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:5>
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>
* needs_tests: 1 => 0
Comment:
Unticked "Needs tests": tests are now in the PR
--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:7>
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>
* type: Cleanup/optimization => Bug
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/31536#comment:9>
* 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>
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>
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>