Opened 17 years ago
Closed 17 years ago
#6263 closed (invalid)
SetEnv not supported in mod_python
Reported by: | eraoul | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | mod_python settings SetEnv | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The docs say that the DJANGO_SETTINGS_MODULE environment variable should be set using SetEnv in an Apache "Location" directive, as follows: <Location "/mysite/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On </Location> However, I get an error message that the DJANGO_SETTINGS_MODULE env. var is undefined. After several hours of debugging, and finding another person with the same problem but without a resolution, I found the following note in the mod_python FAQ itself: "Environment. The apache SetEnv & PassEnv (etc) directives have no effect on the os.environ seen by mod_python. If you need to pass environment to mod_python, you need to set it before starting apache. Or consider using the PythonOption apache directive to pass config info into mod_python scripts." So, can anyone recommend the best way to get DJANGO_SETTINGS_MODULE set up correctly? It seems that SetEnv is not correct here.
Note:
See TracTickets
for help on using tickets.
Django's code accounts for the fact that mod_python does not process SetEnv (see http://code.djangoproject.com/browser/django/trunk/django/core/handlers/modpython.py#L139). Do you really get a message that the environment variable is undefined? Or is the error that the settings module could not be loaded? The latter could be explained by a missing PythonPath statement to include your project's path in the python path for code run under mod_python. The django-users list would probably be a better place to try to work this out, with details of your actual config instead of examples from the doc. The doc is correct.