Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I configure Django runserver to reload when static or non-python files are changed?

Tags:

python

django

By default, Django's runserver command auto reloads the server when python or template files are changed.

Is it possible to configure Django to extend its file monitoring for this purpose to other directories or sets of files, such as JavaScript or CSS files being served statically (during development)?

This would be useful in this scenario: the Django app reads a set of static text files on startup and I would like the server to re-read them when they change, without having to add this specific feature - simply restarting would be fine.

Do I need to start meddling with (or extending) django/utils/autoreload.py ?

like image 908
wodow Avatar asked Oct 31 '22 15:10

wodow


1 Answers

The static files are automatically served from disk, so there is no need to reload the dev server.

But your browser has it's own cache, and is keeping some of your static files in it... To reload it use this shortcut :

Ctrl + Shift + r OR Ctrl + f5

If your on mac use CMD button instead of ctrl

like image 177
The Django Ninja Avatar answered Nov 09 '22 22:11

The Django Ninja