Find more articles in our new Python Knowledge Base

TEMPLATE_STRING_IF_INVALID deprecated

This setting sets the output that the template system should use for invalid (e.g. misspelled) variables. The default value is an empty string ''. This setting is deprecated since Django version 1.8. Set the string_if_invalid option in the OPTIONS of a DjangoTemplates backend instead.

Deprecated feature

Deprecated TEMPLATE_STRING_IF_INVALID setting used.

""" settings.py """

TEMPLATE_STRING_IF_INVALID = 'Invalid variable'

Migration path

As of Django 1.8 you should set string_if_invalid option in the OPTIONS of a DjangoTemplates backend instead.

""" settings.py """

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,
        'DIRS': '/path/to/my/templates',
        'OPTIONS': {
             'string_if_invalid': 'Invalid varialbe!',
         }
    },
]