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
• 14,960 points
85 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,100 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,320 points
38 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,500 points
14 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
47 views
0 votes
1 answer

How can I compare the content of two files in Python?

Assuming that your file unique.txt just contains ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,710 points
33 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
67 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,100 points
64 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,710 points
937 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,100 points
77 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.