#36692 closed Bug (worksforme)
TemplateSyntaxError in clearable_file_input.html due to unbalanced template logic
| Reported by: | Kiran | Owned by: | Kiran |
|---|---|---|---|
| Component: | contrib.admin | Version: | 5.2 |
| Severity: | Normal | Keywords: | admin_widgets, template, AdminFileWidget, TemplateSyntaxError |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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
Change History (4)
comment:1 by , 13 hours ago
| Needs tests: | set |
|---|---|
| Owner: | set to |
| Status: | new → assigned |
comment:2 by , 13 hours ago
comment:3 by , 13 hours ago
| Resolution: | → worksforme |
|---|---|
| Status: | assigned → closed |
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.
comment:4 by , 13 hours ago
| Needs tests: | unset |
|---|
PR