views:

135

answers:

3

This is the error I get in my Apache error log:

[Sun Aug 22 16:52:06 2010] [error] [client 127.0.0.1] ImportError: No module named settings

This is my .wsgi file, per this blog post:

import sys

sys.path.insert(0, '/home/wot/django-projects/aedo')
import settings
import django.core.management
django.core.management.setup_environ(settings)
utility = django.core.management.ManagementUtility()
command = utility.fetch_command('runserver')
command.validate()
import django.conf
import django.utils

django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I've double and triple checked the path name, and that is indeed the path to my project file. I've been trying to get this to work for hours, and have done much googling. I'm asking here as my last resort. I'm desperate!

EDIT: I'm aware that there are similar questions here on SA, and I've read through most all of them, to no avail

+1  A: 

It doesn't work when you put:

import os, sys
sys.path.append('/usr/local/django')    # obs: path to django
sys.path.append('/home/wot/django-projects/aedo')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

in your django.wsgi file?

laurent-rpnet
That wouldn't work as you added the site directory to sys.path and not the parent directory.
Graham Dumpleton
@Graham Dumpleton - true, corrected. It's because I copied from one of my projects using pydev and usually I have 2 times the directory (1 for project name and 1 for src) like `.../django-projects/aedo/aedo/files.py`
laurent-rpnet
+2  A: 

What is the output from running:

ls -las /home/wot/django-projects/aedo/

Is the directory and all the files readable to user that Apache runs as? If they aren't you may get that error.

Also watch talk and look at slides mentioned at:

http://blog.dscpl.com.au/2010/06/sydney-pycon-modwsgi-talk-slides.html

as it discusses permissions issues further.

Graham Dumpleton
Yeah all the files are readable and executable to all users. And thanks will do
starfire
+1  A: 

try changing

os.environ['DJANGO_SETTINGS_MODULE'] = 'aedo.settings'

to

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

Actually I was getting this error too and I did the above. I also changed

ROOT_URLCONF =  'appname.urls' 

to

ROOT_URLCONF =  'urls' 

I hope your settings.py is in the same directory as the wsgi file for this project.

AJ