Pierre de LESPINAY
Pierre de LESPINAY

Reputation: 46178

Django - Apache + WSGI - Import module

I have this kind of tree for my django project

project tree

project/
  apache/
    apache_django_wsgi.conf
    project.wsgi
    ...
  module1/
  module2/
  settings.py
  settings_production.py
  ...

project.wsgi

import os, sys

apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace) 

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings_production'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I'm getting this kind of error (debugged on from the template):

No module named module1

What am I doing wrong ?

Upvotes: 0

Views: 245

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58523

Also add:

sys.path.append(project)

Upvotes: 1

Related Questions