For some reason, I am getting an ImproperlyConfigured error on account of custom middleware.
[Wed Nov 07 20:47:07 2012] [error] [client 158.130.107.158] File does not exist: /home/davidxu/public_html/favicon.ico
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] mod_wsgi (pid=24114): Exception occurred processing WSGI script '/home/davidxu/dev/Penn-Course-Review-api/api/django.wsgi'.
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] Traceback (most recent call last):
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] self.load_middleware()
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Wed Nov 07 20:47:09 2012] [error] [client 158.130.107.158] ImproperlyConfigured: Error importing middleware api.apiconsumer.authenticate: "No module named api.apiconsumer.authenticate"
For reference, here are the relevant parts of the settings.py file:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'api.apiconsumer.authenticate.Authenticate',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'api.courses',
'api.apiconsumer',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
'api.static_content',
'django_extensions', # used for debugging, remove if problematic
'django.contrib.staticfiles',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
And the django.wsgi file for what its worth. (Note, There is a lot of custom stuff in here.)
import os,sys
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
sys.path.append(PROJECT_PATH)
from sandbox_config import *
#Uncomment these two lines to use virtualenv
#activate_this = os.path.join(COURSESAPI_APP_ROOT, "ENV/bin/activate_this.py")
#execfile(activate_this, dict(__file__=activate_this))
sys.path.append(DEV_ROOT)
sys.path.append(COURSESAPI_APP_ROOT)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Unfortunately, at this point I’m not really sure what to try. The error is extremely unhelpful.
- Deleting the line in question caused the next custom middleware to break the program, which makes me think it may be a path issue.
- Google doesn’t seem to have much in the way of help.
Any ideas what the issue may be and what’s worth trying?
Do the following files exist?
If not, then
api/apiconsumer/authenticate.pywon’t be found.Also, try removing
apifrom the prefix in theMIDDLEWARE_CLASSESandINSTALLED_APPS. So, you would have: