On Jul 4, 4:29 pm, Tom Evans <tevans...@googlemail.com> wrote:
> If you have setup your folder layout like this:
> /path/to
>   foo/
>     settings.py
>     bar/
> Where 'foo' is your project and 'foo.bar' is your app, then you will
> need to add /path/to to sys.path.
> If on the other hand 'bar' is how you refer to your app, then you will
> need to add /path/to/foo to sys.path as well.

OK, that's what wasn't clear to me in the documentation. For some
reason, I can refer to 'bar' by itself when using runserver, but with
wsgi I need to add /path/to and /path/to/foo to sys.path (or else
refer to 'foo.bar' everywhere).

> The only reliable and approved way to access your
> settings is:
>
>   from django.conf import settings

Excellent, that makes it a lot tidier.

So now, the only two places I refer to mysite explicitly are:

./django.wsgi:os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
./settings.py:ROOT_URLCONF = 'mysite.urls'

Here's my full django.wsgi, which I have inside the top-level mysite
directory:

~~~~
import os
import sys

path = os.path.dirname(__file__)
if path not in sys.path:
    sys.path.append(path)
path = os.path.normpath(os.path.join(os.path.dirname(__file__),".."))
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()
~~~~

It still fails if I comment out the second bit of path setup (the ".."
one). However, if I change those two lines to

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

and

ROOT_URLCONF = 'urls'

then the app does seem to work happily with just /path/to/mysite in
the path. Is this a reasonable thing to do? (I guess only if you ever
have one django project in your 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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to