banzai banzai - 1 year ago 105
Apache Configuration Question

django cannot recognize settings file

A strange problem occured while trying to configure

to serve a Django project via

My project is a small to-do list implemented here.

When apache tries to run
, returns this error:

Traceback (most recent call last):
File "/var/www/toDoList/myToDoList/", line 19, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python2.7/dist-packages/django/core/", line 13, in get_wsgi_application
File "/usr/local/lib/python2.7/dist-packages/django/", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/dist-packages/django/conf/", line 53, in __getattr__
File "/usr/local/lib/python2.7/dist-packages/django/conf/", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/", line 37, in import_module
ImportError: No module named myToDoList.settings

file is like:

import os
import sys

sys.path.append(' /var/www/toDoList')
sys.path.append(' /var/www/toDoList/myToDoList')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myToDoList.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

and also my
file inside

<VirtualHost *:80>
DocumentRoot "/var/www/toDoList"
ServerName blahblah
WSGIDaemonProcess todolist user=test group=test threads=5
WSGIScriptAlias / /var/www/toDoList/myToDoList/
<Location /todolist>
WSGIProcessGroup todolist
<Directory /var/www/toDoList/toDoList>
Order allow,deny
Allow from all
Alias /static /var/www/toDoList/myToDoList/static/
<Directory /var/www/toDoList/myToDoList/static>
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined

Answer Source

remove that space in sys.path.append

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download