In Django> = 1.8, TEMPLATE_STRING_IF_INVALIDdeprecated in favor of string_if_invalidc settings.TEMPLATES.
If you want to do a bit more than depend on messages DEBUGfrom the registrar django.template, you can trick the following code into django.template.base.FilterExpression.render():
if '%s' in string_if_invalid:
return string_if_invalid % self.var
With a class like the following:
class InvalidString(object):
def __mod__(self, other):
log.error('Missing template variable: "%s"', other)
return u''
def __contains__(self, item):
return item == '%s'
And set string_if_invalidto settings.TEMPLATES:
TEMPLATES = [{
'OPTIONS': {'string_if_invalid': InvalidString()}
}]
source
share