I am looking for a django setting or a programmatic way to make all django template tags display an empty string when the value is None. For example, imagine that I have a django template:
{{cat}} chases {{mouse}}
If both mice and mice are None, this will look like:
None chases None
I know that I can install each of them using {{cat|default:""}} or {{mouse|default_if_none:""}}
However, I am looking for some kind of setting that would allow me to set a default value for all tags without explicitly adding |default:"" to each tag.
I also know a setting called TEMPLATE_STRING_IF_INVALID . However, this option applies only to invalid strings. No is considered valid.
python django django-templates
zzz Sep 28 2018-11-11T00: 00Z
source share