django.core.exceptions.ImproperlyConfigured:启用'django.contrib.auth.context_processors.auth'

时间:2016-01-26 01:33:39

标签: python django django-settings django-1.9

我开始了一个新项目并且正在接受:

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

我跟随django docs for 1.9:

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

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

1 个答案:

答案 0 :(得分:11)

您需要将其添加到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",
            ]
        }
    }
]