Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Django 构建项目,我可以为 Django 创建两个设置文件:production_setting.py 和 development_setting.py,但是,我需要为我的项目配置一些配置文件,并且我正在使用 ConfigParser 来解析这些文件。例如
[部分] 名称=“发展” 版本 = “1.0”
如何将此配置文件拆分为生产和开发?
我们通常在 Django 项目中做的是为每个平台(dev、prod 等)创建所有配置文件的版本,并使用符号链接来选择正确的版本。现在 Windows 正确支持链接,这个解决方案适合所有人。
如果您坚持使用另一个配置文件,请尝试将其设置为仅导入正确配置文件的 Python 文件,这样name="development"您将拥有类似的东西execfile('development_settings.py')
name="development"
execfile('development_settings.py')