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,510 points
6,983 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
• 58,020 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 aryya
• 7,460 points
3,231 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, 2019 in Python by Nymeria
• 3,560 points
2,500 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, 2019 in Python by Fata
• 1,050 points
2,462 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
1,950 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
• 58,020 points
1,729 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 4, 2018 in Python by charlie_brown
• 7,720 points
13,528 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
• 58,020 points
1,001 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP