Django应用程序工作正常,但收到TEMPLATE_ *警告消息 [英] Django app works fine, but getting a TEMPLATE_* warning message
问题描述
当我使用runserver时,它会显示以下警告消息:
When I use runserver, it gives this warning message:
(1_8.W001)独立的TEMPLATE_ *设置已被弃用于
Django 1.8和TEMPLATES字典优先。您必须将
的值设置为默认的TEMPLATES dict:
TEMPLATE_DEBUG。
(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自1.8版以来不推荐使用:在DjangoTemplates后端的OPTIONS中设置debug选项
。
"TEMPLATE_DEBUG Deprecated since version 1.8: Set the 'debug' option in the OPTIONS of a DjangoTemplates backend instead."
这是我的settings.py,我无法尝试解决它:
Here is my settings.py with my futile attempts to fix it:
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
},
}, ]
我在这里缺少什么?
推荐答案
设置 debug
code> OPTIONS 您的模板设置字典。
Set debug
in OPTIONS
dictionary of your templates settings.
DEBUG = True
TEMPLATES = [
{
...
'OPTIONS': {
'debug': DEBUG,
},
},
]
然后从您的设置中删除此行以停止警告
Then remove this line from your settings to stop the warnings
TEMPLATE_DEBUG = DEBUG
这篇关于Django应用程序工作正常,但收到TEMPLATE_ *警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!