Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

python - Django - ImproperlyConfigured: Module "django.contrib.auth.middleware"

I'm running a virtualenv to try to learn Django, but for whatever reason after installing Django and when I try to access the default Django start page, I get the following error in the browser:

A server error occurred. Please contact the administrator.

In the terminal window where I am running the server says the following error:

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

If anyone has any insight as to why I'm getting this error in the virtualenv, I'd appreciate it. I can get the server to run correctly in a non-virtualenv setup, though.

Here is the full stack trace:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__
    self.load_middleware()
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
    mw_class = import_by_path(middleware_path)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/module_loading.py", line 31, in import_by_path
    error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
[16/Sep/2014 22:44:30] "GET / HTTP/1.1" 500 59
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/wsgi.py", line 187, in __call__
    self.load_middleware()
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
    mw_class = import_by_path(middleware_path)
  File "/Users/jruecke/Python/JSON/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/module_loading.py", line 31, in import_by_path
    error_prefix, module_path, class_name))
ImproperlyConfigured: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class
question from:https://stackoverflow.com/questions/25879725/django-improperlyconfigured-module-django-contrib-auth-middleware

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

easy solution

just remove

'django.contrib.auth.middleware.SessionAuthenticationMiddleware',

from

MIDDLEWARE_CLASSES = (
...
...
)

in your project's settings.py

then, it should work!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...