How can I livereload Django templates?
-
@jthill, I am looking for constructive and practical answers and solutions. Google search results didn't provide them. – Nikolay Georgiev Sep 30 '13 at 07:00
-
Alright, let me rephrase that: what's the best thing you've found so far? Show that, and say where you're stuck. As it is now, "constructive and practical answers" is better spelled "someone to research and write an article tailored to my specific needs, which I decline to state". – jthill Sep 30 '13 at 11:57
-
Hi @jthill, to "livereload Django templates" means that when I change my Django templates the change should be automatically propagated to the browser so that I don't have to refresh it myself. I am asking this question because I haven't seen any such solutions from the Google/DuckDuckGo search results. I personally haven't tried to get it working. How can you help? – Nikolay Georgiev Oct 01 '13 at 12:11
4 Answers
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
.

- 2,245
- 1
- 14
- 17
-
1i'm getting an issue where it's indicating 0 watchers when it updates. To get this straight, I run ./manage.py livereload on a separate port and i should be able to point the browser to the runserver path (default 127.0.0.1:8000) and it should automatically update right? I tried to go to the livereload port just to make sure but was getting an error 404. How do I add the browser as a watcher? – David Torrey Nov 03 '17 at 18:25
-
2@DavidTorrey hey, i followed this too, and i'm getting a 404 error, how did you solve it ? – Mohamed Benkedadra Mar 26 '18 at 16:15
-
@HammiCloud what I found is that it wasn't checking the directory correctly. I used the absolute path just to make sure, but it looks something like: "./manage.py livereload path/to/folder after that you go to the ip/port you set up in django (not livereload) and it should auto update – David Torrey Mar 30 '18 at 04:02
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.

- 20,112
- 21
- 72
- 113
-
I set up django-live-reload in my dev environment and no browser plugin is required. django-live-reload is supposed to be based upon the python livereload package so maybe the browser plugin is no longer required. They use websockets which must use technology built into browsers these days? – nmgeek May 01 '16 at 16:06
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.

- 4,593
- 2
- 32
- 21
I found a very simple solution by using Grunt and a livereload browser extension.

- 23,792
- 39
- 118
- 164

- 1,047
- 1
- 12
- 22