我应该怎么做才能使管理服务在Django 1.2中运行

时间:2010-11-12 02:31:22

标签: django admin django-csrf

以前工作得很好。

现在当我试图去/ admin /我有一个错误时:

Module "django.contrib.auth.context_processors" does not define a "csrf" callable request processor

我读到了这个:http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

现在我的设置是:

MIDDLEWARE_CLASSES = (
    'django.middleware.csrf.CsrfMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.csrf.CsrfResponseMiddleware',
)

我需要做些什么才能让它发挥作用?

1 个答案:

答案 0 :(得分:1)

为了使其工作,我必须以不同的顺序编写它:

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',
)