0

以前效果很好。

现在当我试图去 /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',
)

我必须做些什么才能让它工作?

4

1 回答 1

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',
)
于 2010-11-12T04:07:58.700 回答