gpt4 book ai didi

python - Django 应用程序运行良好,但收到 TEMPLATE_* 警告消息

转载 作者:IT老高 更新时间:2023-10-28 21:43:17 25 4
gpt4 key购买 nike

当我使用 runserver 时,它会给出以下警告消息:

(1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG.

引用 Django 文档:

"TEMPLATE_DEBUG Deprecated since version 1.8: Set the 'debug' option in the OPTIONS of a DjangoTemplates backend instead."

这是我的 settings.py,我尝试修复它是徒劳的:

DEBUG = True

TEMPLATE_DEBUG = DEBUG

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'myapp/templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'debug': DEBUG,
'DEBUG': DEBUG,
'TEMPLATE_DEBUG': DEBUG
},
}, ]

我在这里错过了什么?

最佳答案

在模板设置的OPTIONS字典中设置debug

DEBUG = True

TEMPLATES = [
{
...
'OPTIONS': {
'debug': DEBUG,
},
},
]

然后从您的设置中删除此行以停止警告

TEMPLATE_DEBUG = DEBUG

Django docs有关如何更新模板设置的详细说明。

关于python - Django 应用程序运行良好,但收到 TEMPLATE_* 警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32445953/

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