I have the following code in my settings.py file and when I startup my server, the print statement gets called twice. Why is that?
settings.py
if os.environ.get('DJANGO_DEVELOPMENT'):
print('Development Mode')
DEBUG = True
ADMIN_ENABLED = True
Console
Development Mode
Development Mode
Performing system checks...
System check identified no issues (0 silenced).
July 16, 2020 - 20:34:23
Django version 3.0.8, using settings 'MyApp.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
From @iftah's comment on the accepted answer on the accepted answer to "why is init module in django project loaded twice":
[...] Django uses two process for the reloading feature (ie. restart on code change), if you run
./manage.py runserver --noreloadyou get only one process.
So, if you run ./manage.py runserver --noreload it should stop that from happening. Django uses two processes for the reloading feature hence why you are getting the double printing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With