#18518: wsgi.py does not overwrite DJANGO_SETTINGS_MODULE in apache prefork
-------------------------------------+-------------------------------------
Reporter: schaefer@… | Owner: nobody
Type: Bug | Status: reopened
Component: Uncategorized | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Design
Has patch: 0 | decision needed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by benjaoming):
mod_wsgi is very important to Django, and an abundance of Django server
platforms are running it with Apache prefork. So it's a bit bizarre to
introduce a default behaviour that does not support it, nor even mention
the incompatibility. I did not expect it and walked right into a trap with
hours of debugging, because I run older (working!) WSGI scripts mixed with
a broken Django 1.4 auto-generated script, and because there are 30 server
processes, I only had these random processes with an incorrect
DJANGO_SETTINGS_MODULE.
I suggest a commented-out example of how to directly set
DJANGO_SETTINGS_MODULE from wsgi.py so the user is aware and can take
action.
{{{
# Default behaviour is to respect the outside environment
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
# Enable the below line if you are running multiple sites sharing the same
environment.
# This is necessary with for instance Apache prefork + mod_wsgi.
#os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
}}}
I would much prefer having the second line commented in, and the
setdefault as an example. I agree with schaefer that setting the
environment outside of the script is probably a niche -- since wsgi.py is
included in a django project, then it's already a project-specific script!
I could live with a big warning box in the documentation about how to
properly configure the environment and an example of how to customize
wsgi.py -- but having out-of-the-box good behaviour is my preference :)
--
Ticket URL: <https://code.djangoproject.com/ticket/18518#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.