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

0 votes

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 ?

Sep 4, 2018 in Python by bug_seeker
• 15,350 points
346 views

1 answer to this question.

0 votes

There is no need to reload server, but sometimes there is need to copy static files to be visible for the server.

Instead running collectstatic while developing, which copy recently edited static files (like javascript) from one directory to the directory, used by server.

here is a trick:

  • link source directory to behalf of the target (will "override" target directory)
  • or run in loop:

python manage.py collectstatic --noinput

then your server will see all changes in files.

answered Sep 4, 2018 by Priyaj
• 56,520 points

Related Questions In Python

0 votes
1 answer

How can I prevent or alter access to class variables in Python?

The ActiveState solution that Pynt references makes instances of ...READ MORE

answered Dec 5, 2018 in Python by ariaholic
• 7,340 points
60 views
0 votes
1 answer

How do I check which files are open or closed in Python?

Hi, good question. I have a solution ...READ MORE

answered Jan 29 in Python by Nymeria
• 3,520 points
25 views
0 votes
1 answer

What to do when I get and error saying python not recognized as internal or external command?

You need to set up the path ...READ MORE

answered May 28 in Python by Fata
• 1,040 points
28 views
+2 votes
6 answers

How can I change directory or "cd" in Python?

Context Manager: cd import os class cd:     """Context manager for ...READ MORE

answered Oct 18, 2018 in Python by Nabarupa
101 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
142 views
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 56,520 points
117 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,720 points
1,714 views
+1 vote
1 answer

How can I map input to output without using dynamic()

Here am talking about my example you ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 56,520 points
132 views