[Django] #36495: Bug in determining if template file should be autoreloaded in `django.utils.autoreload.notify_file_changed` ?

10 views
Skip to first unread message

Django

unread,
Jul 6, 2025, 4:10:19 PM7/6/25
to django-...@googlegroups.com
#36495: Bug in determining if template file should be autoreloaded in
`django.utils.autoreload.notify_file_changed` ?
-------------------------------------+-------------------------------------
Reporter: dom-rau | Type: Bug
Status: new | Component:
| Uncategorized
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage:
templates,autoreload,watcher,filewatcher| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
This line checks for `not any`
https://github.com/django/django/blame/6df19412aabb7d969f5eab4b2ff41269de89b233/django/utils/autoreload.py#L371

But this line returns `True` for templates:

https://github.com/django/django/blame/6df19412aabb7d969f5eab4b2ff41269de89b233/django/template/autoreload.py#L61

That's why changing template files does not trigger server autoreload.
--
Ticket URL: <https://code.djangoproject.com/ticket/36495>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 7, 2025, 1:50:10 AM7/7/25
to django-...@googlegroups.com
#36495: Bug in determining if template file should be autoreloaded in
`django.utils.autoreload.notify_file_changed` ?
-------------------------------------+-------------------------------------
Reporter: Dominika | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
templates,autoreload,watcher,filewatcher| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* component: Uncategorized => Utilities

Comment:

Thanks for the report, though a couple of things:

- runserver doesn't need to be reloaded for a template change, templates
should just be reread
- the code you referred to seems counter-intuitive and confusing
- out of curiosity, I removed the `not` and ran the test suite and it all
passed

I think there may be some clarification that's required here, and possibly
a test written (because any change to code should break a test somewhere,
somehow) but I don't think any change is necessary from my first point
above.

I believe what that is supposed to do is reload, only if there's a `.py`
file in the templates directory, hence the `return (None)` when the
filename ends with `.py`.
--
Ticket URL: <https://code.djangoproject.com/ticket/36495#comment:1>
Reply all
Reply to author
Forward
0 new messages