The example given in `django/docs/howto/deployment/modwsgi.txt` shows:

~~~~
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
...
    path = '/path/to/mysite'
    if path not in sys.path:
        sys.path.append(path)
~~~~

However, when deploying a project I found that I had to include both
the mysite directory and its parent (that is, both `/path/to/mysite`
and `/path/to`), for it to start under Apache, although I didn't have
any problem using `manage.py runserver` when developing. Without this,
apache gave a 500 result and the following in error.log:

[Mon Jul 04 15:38:42 2011] [error] [client 192.168.122.183]
ImportError: Could not import settings 'mysite.settings' (Is it on
sys.path?): No module named mysite.settings

I am running python 2.6.5 under Ubuntu 10.04.2 LTS

Aside: I found that I could make it work with just `/path/to` in
sys.path if I changed my code to qualify all references to
applications, i.e. use `mysite.app1` and `mysite.app2` everywhere
instead of just `app1` and `app2`. But that's messy. In fact, I would
like to be able to remove all references to `mysite` within the code,
but there are a few places it seems to be necessary; in particular,
whenever I want to pull something out of the toplevel SETTINGS file I
end up writing

~~~~
from mysite import settings
~~~~

Am I missing a trick here? If /path/to/mysite is on the path, would it
be safe to use "import settings" instead of "from mysite import
settings" everywhere?

Or should the documentation show both /path/to and /path/to/mysite
being added to the path?

Thanks,

Brian.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en.

Reply via email to