【问题标题】:Django settings Unknown parameters: TEMPLATE_DEBUGDjango设置未知参数:TEMPLATE_DEBUG
【发布时间】:2016-03-21 19:30:30
【问题描述】:

您好,我正在关注djangoproject site 上的教程,但在我的本地主机上收到错误消息:

Unknown parameters: TEMPLATE_DEBUG

我的 settings.py 如下所示:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'TEMPLATE_DEBUG':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',
            ],
        },
    },
]

我在 TEMPLATE 上添加了“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.

我的模板文件夹在我的应用程序中,即:

my_project_name/polls/templates/polls/index.html

【问题讨论】:

    标签: python django django-1.9


    【解决方案1】:

    我认为你需要这样做:

    DEBUG = True 
    
    TEMPLATES = [
        {
            # something else
            'OPTIONS': {
                'debug': DEBUG,
            },
        },
    ]
    

    Django 过去接受 TEMPLATE_DEBUG 变量,但由于 Django >= 1.8,这不再允许,并按上述说明进行替换。

    Django doc.

    【讨论】:

    • 好的,我现在知道了If it sets TEMPLATE_DEBUG to a value that differs from DEBUG, include that value under the 'debug' key in 'OPTIONS'. 谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    • 2016-07-31
    • 2020-08-03
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2014-02-15
    相关资源
    最近更新 更多