了解DJANGO_SETTINGS_MODULE的用途。

时间:2022-10-12 23:16:09

I wonder which is what of the following:

我想知道以下是什么:

os.environ['DJANGO_SETTINGS_MODULE'] = 'conf.settings'

os.environ[u'DJANGO_SETTINGS_MODULE'] = u'conf'

can you explain?

你能解释一下吗?

1 个解决方案

#1


2  

This defines the settings file name in case of production use.

这将在生产使用时定义设置文件名。

In case of deployment you can use a separate settings file let us say *production_settings.py* which imports from the main settings file settings.py. You could define some separate settings for deployment like SITE_ID, DEBUG etc.

在部署的情况下,可以使用单独的设置文件,例如*production_settings。py*从主设置文件设置中导入。py。您可以为部署定义一些单独的设置,如SITE_ID、DEBUG等。

So in your deployment .wsgi file DJANGO_SETTINGS_MODULE environment variable can be defined to use the separate settings file.

因此,在部署.wsgi文件DJANGO_SETTINGS_MODULE环境变量中可以定义为使用单独的设置文件。

os.environ['DJANGO_SETTINGS_MODULE'] = 'conf.production_settings'

#1


2  

This defines the settings file name in case of production use.

这将在生产使用时定义设置文件名。

In case of deployment you can use a separate settings file let us say *production_settings.py* which imports from the main settings file settings.py. You could define some separate settings for deployment like SITE_ID, DEBUG etc.

在部署的情况下,可以使用单独的设置文件,例如*production_settings。py*从主设置文件设置中导入。py。您可以为部署定义一些单独的设置,如SITE_ID、DEBUG等。

So in your deployment .wsgi file DJANGO_SETTINGS_MODULE environment variable can be defined to use the separate settings file.

因此,在部署.wsgi文件DJANGO_SETTINGS_MODULE环境变量中可以定义为使用单独的设置文件。

os.environ['DJANGO_SETTINGS_MODULE'] = 'conf.production_settings'