Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've finished making a site in django called 'kazbah', and I'm trying to deploy.

All the code for the kazbah site is in /home/git/DjangoProjects/kazbah and my httpd.conf looks like:

<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE kazbah.settings
    PythonDebug On
    PythonPath "['/home/git/DjangoProjects'] + sys.path"
</Location>

I get the following error though:

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

Any idea why this noob is failing?

share|improve this question
add comment

5 Answers

For a project resting under /var/www/bbb (called, "bbb"), I have the following set in the configuration file:

<Location "/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE bbb.settings
        PythonPath "['/var/www/', '/var/www/bbb/'] + sys.path"
        PythonDebug On
</Location>
share|improve this answer
add comment

I've seen this a few times. Every time, it's been because I incorrectly set this line:

SetEnv DJANGO_SETTINGS_MODULE kazbah.settings

Even though it looked right, Django (actually python) was looking one folder off from the one I intended. Try tweaking it, changing it to:

SetEnv DJANGO_SETTINGS_MODULE settings

Also, you can tweak here:

PythonPath "['/home/git/DjangoProjects'] + sys.path"

It might be that you need to set it to:

PythonPath "['/home/git/DjangoProjects/kazbah'] + sys.path"

or something similar. Without seeing your actual folder setup, it's hard to know exactly. :)

share|improve this answer
add comment

Louis, your configuration looks exactly like ones I used before I switched to mod_wsgi, so there must be something else wrong. Maybe you are missing an __init__.py file in /home/git/DjangoProjects/kazbah?

share|improve this answer
add comment

I'm pretty sure you can do the sys.path thing - it's in the django documentation.

I might go over the django doc http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ as I was trying another tutorial(which is a bit outdated I think) - http://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-linux-server/

share|improve this answer
    
Please update your question rather than polluting the answers list with non-answers. This is not a forum thread. –  Carl Meyer Feb 1 '09 at 18:29
add comment

Ok, maybe you have a syntax error in your settings file.

Try this:

$ cd /home/git/DjangoProjects/kazbah
$ python
>>> import settings

Doing it this way will give you a much better error message if there are any errors.

share|improve this answer
    
This works - I don't get any errors –  Louis Sayers Feb 2 '09 at 17:48
add comment

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.