Redefinition of AppConfig.ready()

ぃ、小莉子 提交于 2019-12-05 18:17:14

When you use python manage.py runserver Django start two processes, one for the actual development server and other to reload your application when the code change

You can test it importing os inside your AppConfig class and print the process id inside the ready function like so:

import os

class SomeAppConfig(AppConfig):
    name = 'some_app'

    def ready(self):
        print(os.getpid())

You will see it prints two different processes

You can also start the server without the reload option, and you will see only one process running (and your code print("Redefined ready method in some_app") will only be executed once):

python manage.py runserver --noreload
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!