Apache/WSGI problems, but not on Django Dev Server

125 views
Skip to first unread message

Bobort

unread,
May 6, 2012, 5:54:40 PM5/6/12
to modwsgi
Hello,

I have been scouring all over to figure out what is wrong with my
configuration, and it's probably something simple I have overlooked.
I'm developing a Django application that will run on Apache/mod_wsgi.
In my settings.py file, I set the DATABASES variable and the DEBUG
variable depending on if the website is running from the development
machine.

The code works as expected on the Django development server; DEBUG
gets FALSE. However, it doesn't work as expected on the Apache/
mod_wsgi server; DEBUG gets TRUE. What am I doing wrong? Am I even
at the right group to ask this question?

Thank you very much!

This is what I have:

import socket
if socket.gethostname()=='IT':
DEBUG = True
DATABASES = {
'default': {
'NAME': 'dev_database',
'ENGINE': 'sqlserver_ado',
'HOST': 'server\\SQLSERVER',
'USER': '',
'PASSWORD': '',
'OPTIONS': {
'provider': 'SQLOLEDB',
'use_mars': True,
},
}
}
else:
DEBUG = False
DATABASES = {
'default': {
'NAME': 'live_database',
'ENGINE': 'sqlserver_ado',
'HOST': 'server\\SQLSERVER',
'USER': '',
'PASSWORD': '',
'OPTIONS': {
'provider': 'SQLOLEDB',
'use_mars': True,
},
}
}

Graham Dumpleton

unread,
May 6, 2012, 8:01:35 PM5/6/12
to mod...@googlegroups.com
You need to specify, with any error messages you get, what 'it doesn't
work as expected on the Apache/mod_wsgi server' means.

A few points to note.

1. Web application under Apache would run in a different user to when
you run it manually.
2. The Apache environment doesn't inherit environment variables from
your user account.
3. The user code runs as may not have access to directories you would
when run yourself.
4. The application will not have same working directory, so paths must
be absolute not relative.

Graham
> --
> You received this message because you are subscribed to the Google Groups "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
>

Matthew

unread,
May 7, 2012, 6:16:51 PM5/7/12
to mod...@googlegroups.com
Hi Graham,
 
After spending days debugging this issue, I am a bit embarrassed to say what the problem was, but I think it's a good idea to explain what happened as a matter of completeness.
 
I had two django project folders established: one for the production and one for the development.  I forgot to clean up the production project folder to properly match the development project folder.  In the production project folder, I had a settings.py file, but I also I had a settings folder when I was experimenting with a different way of initializing settings.  In that experiment, DEBUG was always TRUE in the __init__.py file in the settings folder.  After deleting the settings folder, the application worked as expected.
 
Thank you very much for all of your assistance in this matter!
--Matthew
 
Reply all
Reply to author
Forward
0 new messages