0

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.

FinDev
  • 4,437
  • 6
  • 29
  • 29
  • 3
    what do svn and git have to do with executing django through wsgi? – eruciform Jul 22 '10 at 15:43
  • 1
    Relying on process environment variables in web applications is a bad idea. And yes I know that Django itself does that with the DJANGO_SETTINGS_MODULE environment variable. Doesn't change the fact that it is a bad idea. See 'http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Environment_Variables' as well as some of the sections following that for some of the problems that process wide environment variables cause with hosting systems that can host multiple applications in the same process. – Graham Dumpleton Jul 22 '10 at 22:59
  • There are a lot of people who disagree that env variables in web apps are bad, on the basis that env variables are the most secure way to share tokens across processes without having those tokens anywhere on the file system. I personally use them as little as possible, but use them for secret keys and have found no better compromise for those. – Iain Duncan Aug 24 '15 at 00:38

2 Answers2

2

In you app.wsgi file do:

import os
os.environ['MY_ENV_VARIABLE'] = 'value'
# e.g. os.environ['MPLCONFIGDIR'] = '/path/to/config/dir'
Manoj Govindan
  • 72,339
  • 21
  • 134
  • 141
0

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' )
eruciform
  • 7,680
  • 1
  • 35
  • 47