No module named django.core.wsgi with nginx, uwsgi and virtualenv
Question: uwsgi.ini

    
    
    [uwsgi]
    vhost = true
    plugin = python
    socket = /tmp/pjwards.sock
    master = true
    enable-threads = true
    processes = 2
    wsgi-file = /home/ubuntu/workspace/ward/www/fb_archive/wsgi.py
    virtualenv = /home/ubuntu/.virtualenvs/fb_archive
    chdir = /home/ubuntu/workspace/ward/www/fb_archive
    touch-reload = /home/ubuntu/workspace/ward/www/reload
    

wsgi.py

    
    
    import site
    
    import os
    import sys
    from django.core.wsgi import get_wsgi_application
    
    from mezzanine.utils.conf import real_project_name
    
    site.addsitedir('/home/ubuntu/.virtualenvs/fb_archive/lib/python3.4/site-packages')
    sys.path.insert(0, '/home/ubuntu/workspace/ward')
    
    os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                          "%s.settings" % real_project_name("fb_archive"))
    application = get_wsgi_application()
    

uWSGI does not work by `ImportError: No module named django.core.wsgi`. I use
nginx, uwsgi and virtualenv with python3.

    
    
    Traceback (most recent call last):
      File "/home/ubuntu/workspace/ward/www/fb_archive/wsgi.py", line 13, in <module>
        from django.core.wsgi import get_wsgi_application
    ImportError: No module named django.core.wsgi
    unable to load app 0 (mountpoint='') (callable not found or import error)
    


Answer: You're doing the import before you've added your virtualenv to the pythonpath,
so naturally the module can't be found. Move the import to just before the
`get_wsgi_application()` call itself.

