ImportError: Could not import settings 'mysite.settings'

362 views
Skip to first unread message

djandrow

unread,
Feb 6, 2009, 9:37:57 PM2/6/09
to Django users
Hello,

I'm trying to get my django project going on mod_python (this all on
on windows XP)
However when I try to get my project going I get

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

But I have this in my conf:

<Location "/mysite/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['C:/Program Files/Apache2.2/htdocs/mysite'] +
sys.path"
</Location>

What could be the cause of this, there is definetly a settings file?
From reading other posts i got the impression this could be a
permissions issue but I didn't know how to change permissions on
windows and I wasn't sure that was the cause?

Could someone help me please?

Regards,

Andrew

Karen Tracey

unread,
Feb 6, 2009, 9:51:19 PM2/6/09
to django...@googlegroups.com

You've got the 'mysite' part in both the settings spec and the PythonPath.  Given what you have, Python will be looking for:

C:/Program Files/Apache2.2/htdocs/mysite/mysite/settings.py
Then, when that is not found, everyplace else in sys.path + mysite/settings.py

If you are going to be including 'mysite' in your imports (and settings spec), then don't include it in the PythonPath.  Or, drop if from your imports (and settings spec).  (Or, include both the mysite directory and its parent directory in your PythonPath, then you can mix inclusion of 'mysite' in your imports with leaving it out willy-nilly,  but that is rather messy.  Better to pick one alternative and stick with it.)

Also, I'll repeat something I posted in another thread earlier today:

BTW your earlier spec for the PythonPath directive you are using showed you are putting your project code under the default Apache document root htdocs -- that is a bad idea as it may make your source code (including sensitive stuff like database password in settings.py) easily accessible from the web, depending on exactly how you have Apache configured.  Your Django project source code does not need to be under Apache's document root, it simply needs to be found via the PythonPath you specify in your Apache Location block for your Django project.

Karen

djandrow

unread,
Feb 6, 2009, 11:59:19 PM2/6/09
to Django users
Thanks Karen, I've got it all working now.

Regards,

Andrew

On 6 Feb, 21:51, Karen Tracey <kmtra...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages