0

Problem description

I am starting working on a Django project and the server-side rendering template is a little hard to work with. Usually I develop the front-end application with hot module reload server so that I can see the rendered page during development.

However, for Django project I can only view the site by serving and open from browser. If I open the template directly, the include, extends are not processed, hence CSS and JavaScript are not loaded in the base template.

My question is, is there any tool or workflow that can help develop the Django template in offline so that the style and layout can be rendered properly during development?

Edit: justification

As comment mentioned there are some plugins that supports reload the Django page. However, I would like to know whether it is possible to work with the template HTML totally off the Django server, i.e. work with the html static page? There are some scenarios where I feel it is not suitable:

  • A page that refreshes slowly: e.g., slow database query before the page can be rendered.

  • A template that is not accessible normally: e.g., a part of html inside {% if %} that is not normally accessible, such as an error message.

  • A template that is not yet registered in the urlpatterns routes.

Thank you

Yuanyi Wu
  • 199
  • 2
  • 9
  • Does this answer your question? [How to livereload Django templates?](https://stackoverflow.com/questions/19073878/how-to-livereload-django-templates) – tim-mccurrach May 03 '20 at 00:19
  • @Tim Thank you. This looks interesting. However, is it possible to work with the template totally off the Django server? For example if I am developing an error page that I could not run into normally, how could I develop this template page? – Yuanyi Wu May 03 '20 at 01:09
  • I'm not sure. If I was working on a part of the page that was only rendered under certain conditions, I'd probably just remove the condition, or hard-code the relevant values whilst I was working on that feature. Just remember to fix everything once it's ready. For something like a 500 page, you could always add something like `error/` to your `urls.py` which leads to a view which purposefully raises an error. (Again, just delete it afterwards). – tim-mccurrach May 03 '20 at 23:31

0 Answers0