[Django] #36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template logic

2 views
Skip to first unread message

Django

unread,
Oct 28, 2025, 2:46:09 AM10/28/25
to django-...@googlegroups.com
#36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template
logic
-------------------------------------+-------------------------------------
Reporter: keranbyge | Type: Bug
Status: new | Component:
| contrib.admin
Version: 5.2 | Severity: Normal
Keywords: admin_widgets, | Triage Stage:
template, AdminFileWidget, | Unreviewed
TemplateSyntaxError |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Problem
-------
Running the admin_widgets tests locally raised a TemplateSyntaxError from:
django/contrib/admin/templates/admin/widgets/clearable_file_input.html

The template had mismatched conditional block logic (an `{% else %}` / `{%
endif %}` placement issue), which caused the Django template parser to
fail when rendering AdminFileWidget in tests.

Reproduction
----------
Run locally:
python tests/runtests.py admin_widgets -v 2

Observed a TemplateSyntaxError during template parsing in
clearable_file_input.html.

Fix
---
Adjusted the conditional structure in clearable_file_input.html to
properly balance `{% if %}` / `{% else %}` / `{% endif %}` blocks. This
allows the AdminFileWidget to render as expected.

Verification
----------
I ran:
python tests/runtests.py admin_widgets -v 2
All admin_widgets tests passed successfully after the fix.

Patch / PR
----------
PR: https://github.com/keranbyge/django/pull/20008
--
Ticket URL: <https://code.djangoproject.com/ticket/36692>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 28, 2025, 3:20:25 AM10/28/25
to django-...@googlegroups.com
#36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template
logic
-------------------------------------+-------------------------------------
Reporter: Kiran | Owner: Kiran
Type: Bug | Status: assigned
Component: contrib.admin | Version: 5.2
Severity: Normal | Resolution:
Keywords: admin_widgets, | Triage Stage:
template, AdminFileWidget, | Unreviewed
TemplateSyntaxError |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Antoliny):

* needs_tests: 0 => 1
* owner: (none) => Kiran
* status: new => assigned

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

Django

unread,
Oct 28, 2025, 3:20:52 AM10/28/25
to django-...@googlegroups.com
#36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template
logic
-------------------------------------+-------------------------------------
Reporter: Kiran | Owner: Kiran
Type: Bug | Status: assigned
Component: contrib.admin | Version: 5.2
Severity: Normal | Resolution:
Keywords: admin_widgets, | Triage Stage:
template, AdminFileWidget, | Unreviewed
TemplateSyntaxError |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Antoliny):

[https://github.com/django/django/pull/20008 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/36692#comment:2>

Django

unread,
Oct 28, 2025, 3:21:20 AM10/28/25
to django-...@googlegroups.com
#36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template
logic
-------------------------------------+-------------------------------------
Reporter: Kiran | Owner: Kiran
Type: Bug | Status: closed
Component: contrib.admin | Version: 5.2
Severity: Normal | Resolution:
Keywords: admin_widgets, | worksforme
template, AdminFileWidget, | Triage Stage:
TemplateSyntaxError | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Antoliny):

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

Comment:

Thank you for reporting this bug.
However, I was unable to reproduce the issue in my environment.
Currently, all admin_widgets-related tests are passing without any
problems.

Also, I don’t see any syntax issues in clearable_file_input.html.
Could you please provide more details about your test environment and
specify which test within admin_widgets is failing?

Additionally, could you try running the tests again by following this
documentation?
https://docs.djangoproject.com/en/5.2/internals/contributing/writing-code
/unit-tests/

I appreciate your efforts on this, but for now, I’ll go ahead and close
this ticket.
Please feel free to reopen it if new information becomes available.
--
Ticket URL: <https://code.djangoproject.com/ticket/36692#comment:3>

Django

unread,
Oct 28, 2025, 3:22:06 AM10/28/25
to django-...@googlegroups.com
#36692: TemplateSyntaxError in clearable_file_input.html due to unbalanced template
logic
-------------------------------------+-------------------------------------
Reporter: keranbyge | Owner: Kiran
Type: Bug | Status: closed
Component: contrib.admin | Version: 5.2
Severity: Normal | Resolution:
Keywords: admin_widgets, | worksforme
template, AdminFileWidget, | Triage Stage:
TemplateSyntaxError | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Antoliny):

* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36692#comment:4>
Reply all
Reply to author
Forward
0 new messages