在Django中导入设置

时间:2013-04-28 13:44:13

标签: django

我的项目中有三个设置文件:

settings.py

#common settings

development.py

#settings for development
from settings import *
SOME_VARIABLE = some_value1

production.py

#settings for production
from settings import *
SOME_VARIABLE = some_value2

我想在我的django应用中导入 SOME_VARIABLE

  • for manage.py runserver --setttings = development 应该导入 来自 development.py
  • SOME VARIABLE
  • for manage.py runserver --setttings = production 应导入 SOME 来自 production.py
  • 的VARIABLE

1 个答案:

答案 0 :(得分:1)

在您的应用中,您应该使用以下设置:

from django.conf import settings
...
settings.SOME_VARIABLE

你不应该担心他们来自哪里。