gpt4 book ai didi

python - django.core.exceptions.ImproperlyConfigured : Enable 'django.contrib.auth.context_processors.auth'

转载 作者:太空狗 更新时间:2023-10-30 00:35:22 26 4
gpt4 key购买 nike

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

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 中在 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",
]
}
}
]

关于python - django.core.exceptions.ImproperlyConfigured : Enable 'django.contrib.auth.context_processors.auth' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35005647/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com