[Django]-Using TEMPLATE_STRING_IF_INVALID with Django 1.8

6👍

Remove TEMPLATE_STRING_IF_INVALID = 'Invalid: %s' or similar from the settings and add string_if_invalid to the options of the new TEMPLATES setting:

DEBUG = False
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
            ],
            'debug': DEBUG,
            'string_if_invalid': 'Invalid: "%s"'
        },
    },
]

Alternatively if you’re using a production and a development settings file, add following statement to the development settings file:

DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
TEMPLATES[0]['OPTIONS']['context_processors'].append('django.template.context_processors.debug')
TEMPLATES[0]['OPTIONS']['string_if_invalid'] = 'Invalid: "%s"'
👤SaeX

Leave a comment