NotperlyConfigured:导入中间件treeio.core.middleware.user时出错

时间:2013-04-22 23:08:16

标签: python django django-middleware

我收到了这个错误:

[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88] mod_wsgi (pid=19481): Exception occurred processing WSGI script '/home/projects/treeio/treeio.wsgi'.
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88] Traceback (most recent call last):
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 236, in __call__
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88]     self.load_middleware()
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 53, in load_middleware
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88]     raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Mon Apr 22 23:45:42 2013] [error] [client 192.168.1.88] ImproperlyConfigured: Error importing middleware treeio.core.middleware.user: "No module named csrf.middleware"

我有Django 1.5.1和Python 2.7.3。我正在尝试安装Tree.io。

有什么建议吗?

编辑:

MIDDLEWARE_CLASSES = (
    'johnny.middleware.LocalStoreClearMiddleware',
    'johnny.middleware.QueryCacheMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'treeio.core.middleware.domain.DomainMiddleware',
    'treeio.core.middleware.user.SSLMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'treeio.core.middleware.user.AuthMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'treeio.core.middleware.chat.ChatAjaxMiddleware',
    "django.contrib.messages.middleware.MessageMiddleware",
    "treeio.core.middleware.modules.ModuleDetect",
    "minidetector.Middleware",
    "treeio.core.middleware.user.CommonMiddleware",
    "treeio.core.middleware.user.PopupMiddleware",
    "treeio.core.middleware.user.LanguageMiddleware",)

SO:Ubuntu 12.04.2 LTS

2 个答案:

答案 0 :(得分:0)

您在treeio.core.middleware.domain.DomainMiddleware之前加入django.middleware.csrf.CsrfViewMiddlewaredjango.middleware.csrf.CsrfViewMiddleware应位于treeio

之前的列表中

答案 1 :(得分:0)

检查你的Django版本,treeio适用于Django 1.3。你可以改为1.3版本写作

sudo pip install Django==1.3

或者你可以使用virtualenv。