Django settings.py 语句执行两次

ker*_*nic 3 python django

我的文件中有以下代码settings.py,当我启动服务器时,打印语句被调用两次。这是为什么?

设置.py

if os.environ.get('DJANGO_DEVELOPMENT'):
    print('Development Mode')
    DEBUG = True
    ADMIN_ENABLED = True
Run Code Online (Sandbox Code Playgroud)

安慰

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.
Run Code Online (Sandbox Code Playgroud)

小智 7

/sf/answers/147740911/

如果你运行./manage.py runserver --noreload它应该会阻止这种情况发生。Django 使用两个进程来实现重新加载功能,因此您会得到双重打印。