html template reloading #32
Replies: 2 comments 3 replies
-
Hi, We pass our app into gunicorn and then gunicorn is configured with: That should handle all reloading by itself. It does for this example app which has a custom |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply. I did see that setting, however for me changes to the templates to not appear in the browser after reload. I've just cloned the repository and checked this in the pages app. Two things suggested to me that we shouldn't expect the reload to work:
But again I'm not certain if this is the case or if the templates should reload on change and there is something wrong with my setup. Have you been able to confirm the template reloading works recently? Edit So I'm developing on Ubuntu 22.04 on WSL2 on Windows 11. If I try to edit a template from WSL then as I wrote above the templates do not reload. However, if I edit inside a devcontainer i.e. insider the docker container itself, the change is detected and gunicorn reloads so I guess in my setup, gunicorn is not seeing the file system changes originating from the WSL bind mount. In any case, I like to develop inside the devcontainer so its not an issue for me. |
Beta Was this translation helpful? Give feedback.
-
Great work on this Nick.
I just want to check if my understanding of html template reloading is correct.
With the normal django development server, setting the
DEBUG
flag in theTEMPLATES
dict insettings.py
allows changes to templates to be loaded in the browser when the browser is refreshed.However with gunicorn as the server, this does not work.
Is this the expected behaviour or am I doing something wrong?
The only way I've managed to get templates to reload is by adding the following to
gunicorn.py
(as per the docs here):And so, to get the browser to load changes to any template file, I would either have to explicitly list those templates in
reload_extra_files
or I could probably populate this list programmatically.There is a pull request for gunicorn that would make this simpler, but unfortunately it has been sitting unmerged for 4 years.
Is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions