6

我开始了一个新项目并得到:

django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth' in your TEMPLATES setting in order to use the admin application.

我遵循 1.9 的 django 文档:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
    }
]

可能是什么问题(它希望我如何配置)?谢谢

4

1 回答 1

12

您需要将其添加到context_processors列表中OPTIONS

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                "django.contrib.auth.context_processors.auth",
            ]
        }
    }
]
于 2016-01-26T01:42:33.520 回答