0

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!

Bill
  • 2,319
  • 9
  • 29
  • 36

1 Answers1

1

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.)

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Just moments ago googling around, I came across another one of your answers at http://stackoverflow.com/questions/5841531/django-mod-wsgi-apache-importerror-at-no-module-named-djproj-urls I used that and now everything seems to work... Have I done it wrong?? – Bill May 09 '12 at 03:34
  • Not particularly. I always add the project directory to `sys.path` and import directly off it, but I always use mod_wsgi in development so never have to worry about "the other way". – Ignacio Vazquez-Abrams May 09 '12 at 03:36