cookiecutter-django
cookiecutter-django copied to clipboard
Use Django Browser Reload instead a Javascript based one for auto reload
Description
For a long time I used gulp and JS based BrowserReload to auto reload when a change is made in CSS/JS. Recently I converted my projects to use https://github.com/adamchainz/django-browser-reload
Rationale
- It makes sense to use a Python based browser reloader as it should be compatible with all frontend pipelines.
- Reduce the javascript dependencies and the complexity of the gulp file
- django-browser-reload fixes some of the issues I had with the JS one. Multi tab, reload concurrency
- django-browser-reload is made for django by django people and my experience with it has been extremely smooth
this is really cool! Not sure if it would be too dev opinionated, but I +1 it
Nice suggestion, the rationale makes a lot of sense. I would be interested to see what such change would look like, especially with the Docker setup.
Not sure what are the current issues with the Docker setup (I am using a local setup) but django-browser-reload should just work.
It is using django.http.StreamingHttpResponse
under the hood to push state back to the browser and reload the tab this means that's the same webserver than the one serving your we pages. If you can see a page then you should be able to reload it.
The install is not more difficult than Django debug toolbar. I haven't tested with Django Compressor but it should also work out of the box.
Not sure what are the current issues with the Docker setup
It's not so much of any specific issues. In my experience, these types of auto-reload sometimes rely on some extra connections that can be blocked from within the container. May or may not be an issue here, just something to watch out for I guess.
I'm open to review a pull request with such change, would you like to work on this? If you can port what you did so far, we can then assess whether Docker is actually a problem or not.
@browniebroke I have created a pull request, did a bit of manual testing and it is CI valid. There is no way to auto test this, would be keen for people to test what they usually do when they start a project and check if the reload is working