How to livereload Django templates?

2,619 views
Skip to first unread message

Nikolay Georgiev

unread,
Nov 11, 2013, 11:45:42 AM11/11/13
to django-d...@googlegroups.com
Do you know some tips or concrete steps on how to livereload Django templates?

Livereloading means that if I change the HTML Template, CSS or JS files that these files will be automatically reloaded in the browser, without me having to refresh the page manually. This leads to increased productivity. http://livereload.com/

Thank you very much!

Nikolay

Florian Apolloner

unread,
Nov 12, 2013, 5:08:44 PM11/12/13
to django-d...@googlegroups.com
Hi Nikolay,

this mailing lists is about the development of Django itself; you might wanna ask that on django-users

Regards,
Florian

Nikolay Georgiev

unread,
Nov 15, 2013, 4:25:10 AM11/15/13
to django-d...@googlegroups.com
Hi Florian,

after trying to add livereload I came to the conclusion that it should be implemented in Django itself. I managed to add CSS livereload with Cross Browser CSS Injection: http://css-tricks.com/cross-browser-css-injection/, but HTML files cannot be reloaded without knowing how Django templating works. That's why I help is needed not from the user, but from the Django developers.

The easiest implementation would be: If a Django template (HTML) changes, refresh the browser.

How can this be implemented in Django itself?

Greetings,

Nikolay

charettes

unread,
Nov 15, 2013, 10:32:37 AM11/15/13
to django-d...@googlegroups.com
Hi Nikolay,

You could implement such a feature as a third party app by connecting a receiver to the template_rendered signal.

I suggest you take a look at how django-debug-toolbar tracks which template were used.

Please move forward discussion to django-users since, as pointed out by Florian, it's out of django-developpers scope.

Thanks,
Simon

Elyézer Rezende

unread,
Nov 18, 2013, 5:12:26 AM11/18/13
to django-d...@googlegroups.com
On Fri, Nov 15, 2013 at 1:32 PM, charettes <chare...@gmail.com> wrote:
Hi Nikolay,

You could implement such a feature as a third party app by connecting a receiver to the template_rendered signal.

To do a live reload the tool need to know when the template in filesystem is updated, then using template_rendered will not help because need to make a request and the live reload is to automatically do that request when some file is updated.

I don't know if will be possible to add that to django itself, but I think that using some tool like watchdog [1] could help doing that.

Other idea is to override the development server command to monitor the changes to templates files. 


--
Elyézer Rezende
http://elyezer.com

Nikolay Georgiev

unread,
Nov 21, 2013, 9:26:33 PM11/21/13
to django-d...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages