Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having issues trying to deploy my first Django app on ubuntu/Apache. I've followed the guides on djangoproject.com and scoured the internet looking for answers and I'm stuck. I have the basics up and running, but when I try to visit my site (twilightinternal.com) I get the following error:

ImportError: Could not import settings 'twilight_boutique.settings' (Is it on sys.path? Does it have syntax errors?): No module named twilight_boutique.settings

My django code lives in the /root/django_projects/twilight_boutique folder

I have the following information in my sites-available/twilightinternal:

<VirtualHost *>
        ServerAdmin shawn@coldfeetstudios.com
        ServerName www.twilightinternal.com
        ServerAlias twilightinternal.com

        DirectoryIndex index.html
        DocumentRoot /var/www/twilightinternal/

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Location "/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE twilight_boutique.settings
                PythonOption django.root /root/django_projects/twilight_boutique
                PythonDebug Off
                PythonPath "['/root/django_projects', '/var/www'] + sys.path"
        </Location>

</VirtualHost>   

I'm really stuck and any help would be greatly appreciated.

share|improve this question
    
here is answer: stackoverflow.com/questions/1216340/… –  Farhan Nov 10 '11 at 18:03
    
That case was different. The DJANGO_SETTINGS_MODULE only had settings. –  Jeff Strunk Nov 10 '11 at 19:27

1 Answer 1

up vote 1 down vote accepted

First, you should use mod_wsgi if you can or FastCGI as a fallback option.

Your Apache settings look correct, so it is probably your settings.py. It is very likely a permissions problem. Is there a particular reason you are running it from /root? Typically, apache does not run as root and will not be able to read any files under /root. Try moving the project to another location.

If that doesn't help, here are some other debugging steps to try.

Does the development server work properly?

cd /root/django_projects/twilight_boutique
python manage.py runserver

If that fails, you have a syntax error in your settings file.

You could also try using the python shell to try to debug this. Run python from any directory and run the following code:

import sys
sys.path.insert(0, '/root/django_projects')
import twilight_boutique.settings
share|improve this answer
    
Running under root was my problem. I now have a django error to work through, but I'm past the server related stuff. Thanks so much. –  Shawn Inman Nov 10 '11 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.