django.core.exceptions.ImproperlyConfigured:启用'django.contrib.auth.context_processors.auth'
django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth'
我开始了一个新项目并得到:
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,
}
]
可能是什么问题(它要我如何配置)?谢谢
您需要将其添加到 context_processors
list in the 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",
]
}
}
]
我开始了一个新项目并得到:
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,
}
]
可能是什么问题(它要我如何配置)?谢谢
您需要将其添加到 context_processors
list in the 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",
]
}
}
]