Nissan911
Nissan911

Reputation: 293

django: wsgi import setting error modeule named mysite.settings not found

Hello i have spend 2 days on this error. couldnt figure it out.

an 21 00:19:50 2011] [error] [client 127.0.0.1] ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings

django.wsgi located in /user/local/django/apache

import os, sys
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi

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

my django project named mysite: located in /user/local/django/mysite/scr/ (here contains settings.py init.py and etc...)

apache conf

Alias /media/ /usr/local/django/media
<Directory /usr/local/django/media>
Order deny,allow
Allow from all
</Directory>

<Directory /usr/local/django/apache/>
Order deny,allow
Allow from all
</Directory>



WSGIScriptAlias / /usr/local/django/apache/django.wsgi

i have changed the mysite folder above with permission 777 to avoid any permission issues. and i restart httpd service everytime.

apache starts up and find django.wsig. but it can not find the setting file specifed in it.

and i add the path to $PATH manually and echo it. it is there. and i restart httpd. then the path i added is gone...

anyone knows what is going on?

thanks

Upvotes: 3

Views: 6540

Answers (3)

Dan
Dan

Reputation: 1536

A couple of things you could try.

Does the test server "runserver' work? If it doesn't it may be that you have an error in your settings file or one of the other files it loads

The order of 'INSTALLED APPS' can be important. For one of my projects this error went away when I changed the order of installed apps.

The answers to this question I asked a bit ago may be helpful. How do I stop getting ImportError: Could not import settings 'mofin.settings' when using django with wsgi?

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599926

If settings.py is in /usr/local/django/mysite/scr/, then fairly obviously you should use:

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

Upvotes: 3

Original answer was me mistakenly thinking your sys.path was incorrect.

New theory is that you say your settings.py lives in .../django/mysite/scr/, so specifying mysite.settings wouldn't be valid.

Technically, assuming mysite has an __init__.py file, the path to your settings file is mysite.scr.settings

Upvotes: 2

Related Questions