views:

573

answers:

5

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?

A: 

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/

Louis Sayers
Please update your question rather than polluting the answers list with non-answers. This is not a forum thread.
Carl Meyer
+2  A: 

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>
ayaz
+1  A: 

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?

Van Gale
+2  A: 

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. :)

bigmattyh
A: 

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.

Van Gale
This works - I don't get any errors
Louis Sayers