Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django settings.py statement executed twice [duplicate]

Tags:

python

django

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.
like image 678
kernelpanic Avatar asked Jul 12 '26 16:07

kernelpanic


1 Answers

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 --noreload you 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.

like image 119
Harben Avatar answered Jul 14 '26 07:07

Harben