[Fixed]-Django + mod_wsgi + apache: ImportError at / No module named djproj.urls


Either change all your module/package entries and imports to exclude the project name, or put /srv/www/site.com in sys.path as well.


I second Ignacio Vazquez-Abrams’s answer. You must add the path to your project directory as well as the path to its parent directory to sys.path. Here is an example of the WSGI script file I use. I keep the file inside the project directory.

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))

os.environ["DJANGO_SETTINGS_MODULE"] = "PROJECT_NAME.settings"

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()


Seconding ayaz’ answer. It’s important that the paths you’re specifying be at the beginning of the search path, which means you need to use insert..

Here’s mine. When I was doing an ‘append’ I was getting intermittent issues. This made it rock solid. Hope this helps.

sys.path.insert(0, '/srv/www/Appname')
sys.path.insert(1, '/srv/www')


try following this tutorial – http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/

Make sure to add both Django directory and Django Project Directory to system path. your wsgi.py should look like

import os,sys

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

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


What corrected this error for me —

Changing settings.py from:


To this:

ROOT_URLCONF = ‘myproject.urls’



where you have djproj.urls maybe try just urls


Leave a comment