-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
runserver_plus template reloading #1775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runserver_plus template reloading #1775
Conversation
…y other receivers can consume it
The actions fail due to #1777 |
c9152b0
to
8fffec2
Compare
@trbs thanks for mergin. Is there something of a schedule for a new release? A new release would make it possible for cookiecutter/cookiecutter-django#4028 to upgrade to Django 4.1. |
@trbs or someone else do you have some spare time for a release? |
Hello everyone! I have just tried django-extensions from git and it looks like that this patch does not trigger template reload. Digging through werkzeug code it looks to me that |
@bmihelac Can you tell me more about your setup? How does your template loader settings look like? Do you use the StatReloader? |
@foarsitter thanks for your time. I believe that template loaders are standard from what you get when you start new project + DIRS: TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
BASE_DIR / "templates",
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
] If ./manage.py runserver_plus --extra-file="*.html" Changing ./manage.py runserver_plus --extra-file="test.html" Changing
let me know if you need any more information. |
The template reload does reset the cache of the cached.loader, it does not restart werkzeug. So there is no trace in the logs. But the evidence you provide is strong. I verified the patch and here it works like a charm. Im on Linux using Docker, using the statloader and Django 4.1 How do you install the main branch through pip? What OS you are on? |
I am on linux, Django 4.1, stat reloader, installed django-extensions with: pip install git+https://github.com/django-extensions/django-extensions I have tried once more right now and cached template is displayed. |
Do you have time to craft a minimal viable project and share it on GitHub? Currently Im on holiday but next week I can dive into it. |
@foarsitter sure, i'll create test project for this ASAP |
@bmihelac you are right about that the
Update: something like this seems to work: main...foarsitter:django-extensions:runserver_plus_autoreload_templates_statloader |
@foarsitter what do you think about using dango.template.autoreload.get_template_directories to simplify getting template directories? I wonder about the case of adding new templates after dev server is started - would they be watched or |
@bmihelac my attempt to mimic
|
This brought my on an idea to create a workaround except each |
I'm having the same problem here, changes to templates don't trigger a change event. Only when using the default runserver. Anyone else with same problem? |
The cached.Loader template loader is default in Django 4.1, even with
DEBUG=True
.To take advantage of this loader in development the
runserver
command is extended to invalidated the cache when an template is changed.runserver_plus
does not listen to changes in.html
and does not invalidate the template cache on change.This pull requests adds the
.html
suffix toextra_files
so the Werkzeug reloader fires the correct signals. By firing thedjango.utils.autoreload.file_changed
event on each change thedjango.template.autoreload.template_changed
receiver can triggerreset_loaders
when needed.Fixes #1766