Django源码

1. 执行manager.py文件 启动项目

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "student.settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)
View Code

2. 执行execute_from_command_line函数

"""
1. 实例化ManagementUtility类
2. 执行utility.execute()方法

"""
def execute_from_command_line(argv=None):
    
    utility = ManagementUtility(argv)
    utility.execute()
View Code

3. 实例化ManagementUtility类,执行对象的execute方法 

 

 

 

 

 

 

 

 

 

#execute_from_command_line 执行的操作

1. 实例化ManagementUtility类
        1. 设置self.argv=['/Users/huaixiaozi/PycharmProjects/outline/student/manage.py', 'runserver', '8001']
        2. 设置self.prog_name=manage.py

2. 执行对象的execute()方法
        1. 设置变量subcommand=runserver

  

from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
View Code

3. 

posted @ 2018-03-06 20:09  golangav  阅读(174)  评论(0编辑  收藏  举报