Django - 不正确配置:模块“django.contrib.auth.middleware” [英] Django - ImproperlyConfigured: Module "django.contrib.auth.middleware"

查看:1848
本文介绍了Django - 不正确配置:模块“django.contrib.auth.middleware”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个virtualenv来尝试学习Django,但是无论什么原因,安装Django之后,当我尝试访问默认的Django起始页时,我在浏览器中收到以下错误:

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:


不正确配置:模块django.contrib.auth.middleware未定义SessionAuthenticationMiddleware属性/类

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

如果有任何人有任何见解,为什么我在virtualenv中得到这个错误,我会很感激。我可以让服务器在非virtualenv设置中正常运行。

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.

这是完整的堆栈跟踪:

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


推荐答案

简单解决方案

easy solution

只需删除

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

来自

MIDDLEWARE_CLASSES = (
...
...
)

中的c>

它应该工作!

这篇关于Django - 不正确配置:模块“django.contrib.auth.middleware”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆