Django sys.path.append for project *and* app needed under WSGI

Posted by GerardJP on Stack Overflow See other posts from Stack Overflow or by GerardJP
Published on 2010-03-25T13:05:31Z Indexed on 2010/04/07 20:33 UTC
Read the original article Hit count: 266

Filed under:
|

Hi all,

Could somebody give me a pointer on why I need to add my project root path to the python path as well as the application itself in my WSGI file?

Project base is called 'djapp', the application is called 'myapp'.

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../djapp')

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

If I omit the line with "/../djapp/" the log tells my that 'myapp' can not be imported, even though 'djapp.settings' is. (validating 'djapp' was imported)

It al runs properly with the ./manage.py command. there's a __init__ in the project folder.

For testings sake, I see the same issue using addsitedir:

site.addsitedir('/home/user/web/project/')
site.addsitedir('/home/user/web/project/djapp')

Thanx a lot.

Gerard.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-wsgi