经过网上查询和自己思考,把django项目主要几个文件写出来
1.wsgi.py
官网解释:
When the WSGI server loads your application, Django needs to import the settings module — that’s where your entire application is defined.
Django uses the DJANGO_SETTINGS_MODULE
environment variable to locate the appropriate settings module. It must contain the dotted path to the settings module. You can use a different value for development and production; it all depends on how you organize your settings.
If this variable isn’t set, the default wsgi.py
sets it to mysite.settings
, where mysite
is the name of your project. That’s how runserver
discovers the default settings file by default.
When the WSGI server loads your application, Django needs to import the settings module — that’s where your entire application is defined.
Django uses the DJANGO_SETTINGS_MODULE
environment variable to locate the appropriate settings module. It must contain the dotted path to the settings module. You can use a different value for development and production; it all depends on how you organize your settings.
If this variable isn’t set, the default wsgi.py
sets it to mysite.settings
, where mysite
is the name of your project. That’s how runserver
discovers the default settings file by default.
翻译:
使用WSGI进行部署的关键概念是application
应用程序服务器用于与您的代码进行通信的可调用代码。它通常作为一个application
在服务器可访问的Python模块中命名的对象提供。
该startproject
命令创建一个<project_name>/wsgi.py
包含这种application
可调用的文件 。
它用于Django的开发服务器和生产WSGI部署。
WSGI服务器application
从其配置获取可调用的路径。Django的内置服务器,即runserver
命令,从WSGI_APPLICATION
设置中读取它。默认情况下,它被设置为<project_name>.wsgi.application
,指向application
可调用的<project_name>/wsgi.py
。
当WSGI服务器加载你的应用程序时,Django需要导入设置模块 - 这是你的整个应用程序被定义的地方。
Django使用 DJANGO_SETTINGS_MODULE
环境变量来定位适当的设置模块。它必须包含设置模块的虚线路径。您可以使用不同的价值进行开发和生产; 这一切都取决于你如何组织你的设置。
如果未设置此变量,则默认wsgi.py
将其设置为 mysite.settings
,其中mysite
是项目的名称。这是