views:

280

answers:

1

I'm running apache / os x and serving up localhost pages to test django on my laptop. I've already verified all the following

• python is working fine and up to date (2.5.1)

• django available to python and up to date (1,1,0, 'final', 0)

• mod_wsgi module is loaded among apache modules in my apache config - Check!

• path to django application is in vhost.conf with proper permissions - OK!

• mod_wsgi vhost.conf tested and working fine in the intended django application directory - test application through localhost pulls up 200 OK, 'hello world!'

• django default application has been created using 'django-admin.py startproject mysite'

• django application works fine on port 8000 using development server - OK!

• path to the new django application (called mysite) is on python path - verified!

All this is verified and when I run the wsgi script with DJANGO_SETTINGS_MODULE settings.py and load the django app, I still get 'could not import settings 'mysite.settings' etc.

Since this seems to cover the basic troubleshooting, are there any further steps I could take to find out the problem?

================

Python path is valid, verified. The django development server runs fine with the command line on port 8000.

The apache config has the typical module loaded: LoadModule wsgi_module libexec/apache2/mod_wsgi.so

vhost.conf is included from apache config as follows

NameVirtualHost: *.80

    <Directory /users/useracct/scripts/python>
            Order allow,deny
            Allow from all
    </Directory>

    <Directory /Library/WebServer/Documents>
            Order allow,deny
            Allow from all
    </Directory>
    WSGIDaemonProcess localhost user=username group=staff threads=25
    WSGIProcessGroup localhost

    WSGIScriptAlias /mysite /users/useracct/Sites/mysite/mysite.wsgi

    <Directory /users/useracct/Sites/mysite/>
            Allow from all
    </Directory>

    DocumentRoot /Users/useracct/Sites/

Virtualenv is not set up with this account, so that is one less possible cause.

=======================

and the wsgi script file (trying to keep it minimal):


import os, sys
path = '/users/usracct/sites/mysite'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
+2  A: 

Try adding /users/useracct/Sites/ a to your pythonpath in your wsgi file:

import os
import sys
.....
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
....
reech
that works. thanks to all!!!
Pythovore
and btw, mod_wsgi is a great thing, but i find the python environment remains very hard to troubleshoot in. One thing I'm working on is a more feedback-oriented environment. Some way to maximize the test loop - but no GUIs. When you rely on a GUI it really starts to go downhill. Now that's a topic for debate.
Pythovore
Pythovore. Did you actually read the Django integration guide on the mod_wsgi site? It tells you quite explicitly about the need to add that directory. The answer here is being a bit smart about it, ie., by trying to calculate it relative to WSGI script file, but the need to add the directory is described in the documentation. Read 'http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango'.
Graham Dumpleton
Here is where I say 'D'oh' and thanks.
Pythovore