[Django]-What is StatReloader while running Django?

28👍

Its the class that django uses to auto reload the development server whenever you make code changes .

Specifically, determined within the get_reloader method where watchman is an alternative for linux / macOS

If you’re using Linux or MacOS and install both pywatchman and the Watchman service, kernel signals will be used to autoreload the server (rather than polling file modification timestamps each second). This offers better performance on large projects, reduced response time after code changes, more robust change detection, and a reduction in power usage.

(Runserver docs)

No idea why its in red in pycharm but if you really wanted to you can disable it with the --noreload flag

👤Sayse

8👍

in my case, I changed the option DEBUG= True for DEBUG=False in my file settings.py, since then its working.

before in settings.py:

#SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

in docker :

$ docker run  container_name 

Watching for file changes with StatReloader

after in settings.py:

#SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False 

in docker:

$ docker run container_name
[24/Mar/2020 10:10:19] "GET /health HTTP/1.1" 200 5299

5👍

Use --noreload flag when running the development server

python manage.py runserver 0.0.0.0:8000 --noreload

Reference is here.

👤sareno

0👍

the main function of statreloader is to automatically update your site by changing a file of your django project, and you won’t need to run the command again.

Leave a comment