Python – Django apache mod-python setup (vista)

apachedjangomod-pythonsettingsvista64

I am trying to setup my development environment on my local vista machine (django+apache+mod-python+postgres) and for some reason I can't load the settings.

Everything works on the built-in server but not under apache.

Here is my httpd.conf

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

And Error:

ImportError at /

No module named main.urls

Request Method:     GET
Request URL:    http://localhost/
Exception Type:     ImportError
Exception Value:    

No module named main.urls

Exception Location: 
C:\Python25\lib\site-packages\django\utils\importlib.py in import_module, line 35
Python Executable:  C:\Program Files (x86)\Apache Software 
Foundation\Apache2.2\bin\httpd.exe
Python Version:     2.5.4
Python Path:    ['C:/django', 'C:\\Windows\\system32\\python25.zip', 
'C:\\Python25\\Lib', 'C:\\Python25\\DLLs', 'C:\\Python25\\Lib\\lib-tk', 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2', 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2/_externals']

Best Solution

Where does your code for your project reside? The parent of the folder that contains your project should be on the Python path. Assuming main is your project name, and it's in C:\django\projects\main\ you'd need to have c:\django\projects\ on your python path.

Either that, or main.urls should be movies.urls in your settings.py.

Related Question