Django app works fine, but getting a TEMPLATE_* warning message

不问归期 提交于 2019-12-02 19:58:05

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

See the Django docs for detailed instructions how to update your template settings.

OWADVL

remove APP_DIRS and add the loaders inside the templates. example:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ,
        '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',
            ],
            'loaders': [
               'django_jinja.loaders.AppLoader',
                'django_jinja.loaders.FileSystemLoader',
            ]
        },
    },
]

From settings.py remove all this:

    TEMPLATE_DIRS = (
        os.path.join(BASE_DIR,  'templates'),
    )

Then add 'templates' here:

    TEMPLATES = [
    {
        ...
        'DIRS': [here],
        ...
            ],
        },
    },
]
Maxim Agapov

This is the best solution:

Change this line to:

TEMPLATES[0]['OPTIONS']['debug'] = True

which should fix the warning.

I have found it here.

Joni

In my setting.py in django, there is not this script :

TEMPLATE_DEBUG = DEBUG

and

'debug': DEBUG, 'DEBUG': DEBUG, 'TEMPLATE_DEBUG': DEBUG

Maybe you can try to remove them and run it again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!