title: Django mod_wsgi: Exception occurred processing wsgi script
body: <p>I am deploying a django project and facing this error.</p>
  
  <p>My project structure like below:</p>
  
  <pre><code>my_project
     my_project
        urls.py
        settings.py
        index.wsgi
        home
           views.py
           models.py
           .........
  
      requirements.txt
      manage.py
  </code></pre>
  
  <p>And my index.wsgi looks like below:</p>
  
  <pre><code>import os
  import sys
  import site
  
  # Add the site-packages of the chosen virtualenv to work with
  site.addsitedir('~/.virtualenvs/my_project/lib/python2.6/site-packages/')
  
  # Add the app's directory to the PYTHONPATH
  sys.path.append('/var/www/uni/my_project')
  sys.path.append('/var/www/uni/my_project/home')
  
  os.environ['DJANGO_SETTINGS_MODULE'] = 'my_project.settings'
  
  # Activate your virtual env
  activate_env=os.path.expanduser("/home/user/.virtualenvs/my_project/bin/activate_this.py")
  execfile(activate_env, dict(__file__=activate_env))
  
  import django.core.handlers.wsgi
  application = django.core.handlers.wsgi.WSGIHandler()
  </code></pre>
  
  <p>And in my virtualhost, the configuration is like below :</p>
  
  <pre><code>    &lt;Directory /var/www/uni/my_project/templates/static&gt;
          Allow from all
       &lt;/Directory&gt;  
    WSGIScriptAlias / /var/uni/news/my_project/my_project/index.wsgi 
  </code></pre>
  
  <p>The apache error.log is shown as:</p>
  
  <pre><code>mod_wsgi (pid=27330): Exception occurred processing WSGI script '/var/www/uni/my_project/my_project/index.wsgi'.
  [Mon Jun 09 14:23:53 2014] [error] [client ip] Traceback (most recent call last):
  [Mon Jun 09 14:23:53 2014] [error] [client ip]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
  [Mon Jun 09 14:23:53 2014] [error] [client ip]     self.load_middleware()
  [Mon Jun 09 14:23:53 2014] [error] [client ip]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
  [Mon Jun 09 14:23:53 2014] [error] [client ip]     for middleware_path in settings.MIDDLEWARE_CLASSES:
  [Mon Jun 09 14:23:53 2014] [error] [client ip]   File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 184, in inner
  [Mon Jun 09 14:23:53 2014] [error] [client ip]     self._setup()
  [Mon Jun 09 14:23:53 2014] [error] [client ip]   File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 42, in _setup
  [Mon Jun 09 14:23:53 2014] [error] [client ip]     self._wrapped = Settings(settings_module)
  [Mon Jun 09 14:23:53 2014] [error] [client ip]   File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 95, in __init__
  [Mon Jun 09 14:23:53 2014] [error] [client ip]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
  [Mon Jun 09 14:23:53 2014] [error] [client ip] ImportError: Could not import settings 'my_project.settings' (Is it on sys.path?): No module named my_project.settings
  </code></pre>
  
  <p>I went through the mod_wsgi and djnago docs. I know the project structure is not maintaining all the best practices. I will change it later but before that I need to go it live.</p>
  
  <p>I tried by changing file permissions and all the changes that mentioned in same questions.</p>
  
  <p>So, I am assuming I am doing something wrong.</p>
  
  <p>Where is the mis configuration in the above files?</p>
  
  <p>Thanks. </p>