Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm deploying a django app, but I can't seem get the settings correct in the Apache configuration. I've put my django app in /path/to/mysite.com/teabag/current/

  DirectoryIndex index.html
  DocumentRoot /path/to/mysite.com/teabag/current/

  <Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings_production
    PythonPath "['/path/to/mysite.com/teabag/current'] + sys.path"
    PythonDebug On
  </Location>

  <Location "/media/">
    SetHandler None
  </Location>

  <LocationMatch "\.(jpg|gif|png)$">
    SetHandler None
  </LocationMatch>

But it's giving me this error:

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

I had a suspicion that my python path is incorrect. Should it be one level above at /path/to/mysite.com/teabag?, and thus the setting should be "current.settings_production"

I'm a little stuck, and any help would be appreciated, thanks.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

The value you use for PythonPath should include the parent directories of all the modules you are going to import in your application. It should also include the parent directory of the DJANGO_SETTINGS_MODULE location.

I good guess would be:

SetEnv DJANGO_SETTINGS_MODULE current.settings_production
PythonPath "['/path/to/mysite.com/teabag/'] + sys.path"
share|improve this answer
add comment

I agree with rkthkr on the answer to your question but I noticed this.

DocumentRoot /path/to/mysite.com/teabag/current/

Wouldn't that cause a security problem? That would give someone access to your application code. There should be no need to point your DocumentRoot to your application directory. All your static media should be served out of a separate directory. If you are on a Linux system you could symlink your media from your application directory to your DocumentRoot directory.

share|improve this answer
    
It doesn't seem like it. Unless you turn off mod_python with sethandler, it will interpret it as a route that needs to be passed into urls.py. And unless it's there in the route, it'll just error out –  Wilhelm Jun 9 '09 at 18:26
2  
Irrespective of whether mod_python may intercept the request, it is still very dangerous to stick any source code under DocumentRoot. This is because the DocumentRoot directory would have 'Allow from all', so if Apache was is in some way (mis)configured to allow serving from that location through some other URL, there would be nothing to stop the code being downloaded. So, for self protection, do not do it. –  Graham Dumpleton Jun 27 '09 at 11:01
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.