Where and how do I set an environmental variable using mod-wsgi and django?

試著忘記壹切 提交于 2019-12-24 20:13:07

问题


I'm trying to use this env variable to specify the path for my templates and it will probably be easier to do this using git or svn.


回答1:


In you app.wsgi file do:

import os
os.environ['MY_ENV_VARIABLE'] = 'value'
# e.g. os.environ['MPLCONFIGDIR'] = '/path/to/config/dir'



回答2:


The reference material is here. But the operative line for your project path (in case that's what you mean) is:

sys.path.append('/path/to/project')

However, your template path is set within your settings.py file:

TEMPLATE_DIRS = ( '/path/to/templatedir1', '/path/to/templatedir2' )


来源:https://stackoverflow.com/questions/3310419/where-and-how-do-i-set-an-environmental-variable-using-mod-wsgi-and-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!