3๐
I found a very simple solution by using Grunt and a livereload browser extension.
18๐
I maintain the package django-livereload-server that adds both the livereload javascript and provides a livereload server in an easy django way. All you need to do is:
pip install django-livereload-server
- add
'livereload'
toINSTALLED_APPS
- add
'livereload.middleware.LiveReloadScript'
toMIDDLEWARE_CLASSES
- start the livereload server/file watcher with
./manage.py livereload
.
- [Django]-Django choices. How to set default option?
- [Django]-Add a count field to a django rest framework serializer
- [Django]-How do I match the question mark character in a Django URL?
12๐
I found a Python native solution which is easy to setup and works well, Python LiveReload (doc).
pip install livereload
livereload /path/to/monitor
You still have to install the browser plugin. The plugin and LiveReload use port 35729
to talk (customizable), but you need to point the browser to the port specified via runserver. For example:
python manage.py runserver example.com:8000
In this case the live reloaded url is http://example.com:8000, and when you change your templates the page is refreshed automatically.
As a final note, Python live reload can also be used programmatically and supports wsgi applications.
- [Django]-Django test runner not finding tests
- [Django]-Multiple applications with django
- [Django]-Setting up Mimetype when using TemplateView in Django
4๐
You can use python-livereload like this:
pip install livereload
livereload project/static
And in order to make this work add this snippet into your base.html
:
<script type="text/javascript" src="http://127.0.0.1:35729/livereload.js"></script>
Then run ./manage.py runserver
and it should work.
- [Django]-How to update multiple fields of a django model instance?
- [Django]-How to reverse a name to a absolute url in django template?
- [Django]-Best practices for adding .gitignore file for Python projects?