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

cod*_*321 5 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.
Run Code Online (Sandbox Code Playgroud)

我跟随django docs 1.9:

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

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

ozg*_*gur 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",
            ]
        }
    }
]
Run Code Online (Sandbox Code Playgroud)