Deploying django - "ImportError" for Apache VirtualHost and mod_wsgi
Question: I'm deploying django on port 81 of my webserver. This is to get it off the
development server, but I'm not ready to have it be served as the root on port
80.

The problem is that any time I try to access any page on port 81, I see the
django error screen and it always says: `ImportError at / No module named
mysite.urls`

## httpd.conf

    
    
    Listen 81
    
    NameVirtualHost *:81
    
    <VirtualHost *:81>
       DocumentRoot /home/bill/Desktop/mysite
    
       WSGIScriptAlias / /home/bill/Desktop/mysite/django.wsgi
       <Directory /home/bill/Desktop/mysite>
          Order allow,deny
          Allow from all
       </Directory>
    </VirtualHost>
    

## /home/bill/Desktop/mysite/django.wsgi

    
    
    import os
    import sys
    
    sys.path.append('/home/bill/Desktop/mysite')
    
    os.environ['PYTHON_EGG_CACHE'] = '/home/bill/Desktop/mysite/.python-egg'
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

## in mysite/settings.py

    
    
    ...
    ROOT_URLCONF = 'mysite.urls'
    ...
    

I know for a fact that `ROOT_URLCONF = 'mysite.urls'` is getting loaded,
because if I change it to anything else (like "test"), I get `ImportError at /
No module named test`

Any thoughts about where this deployment has gone wrong? Thanks in advance!


Answer: Your deployment is fine. Your code needs to be corrected, in that it should
only be importing (and subsequently using) `urls`.

(Although `os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'` is sort of
redundant.)

