简体   繁体   中英

Error with django middleware settings

I am using django 1.7 and my middleware settings look like this:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

I am using apache2 as my web server. As the settings are, I get a 500 internal server error when I try to access my site. However, when I comment out 'django.contrib.auth.middleware.SessionAuthenticationMiddleware' , everything works fine. Is there a related setting I'm missing? The apache error log is as follows:

ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class

I experienced the same problem myself. The problem was caused by an installation that conflicted with certain "ssl" libraries installed by django. Uninstall and re-install, solves this problem most efficiently.

I recommend, uninstall all the django versions:

"sudo pip uninstall django" several times until all the django distributions are uninstalled.

Then, re-install

"sudo pip install django"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM