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!

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Just moments ago googling around, I came across another one of your answers at stackoverflow.com/questions/5841531/… I used that and now everything seems to work... Have I done it wrong??
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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.