django template display item value or empty string

You want the default_if_none template filter, (doc).

default_if_none will display the given string if the variable is ‘None’.

default will display the string if the variable evaluates to False, ie empty strings, empty lists etc

{{ item.somefield|default_if_none:"" }}
{{ item.somefield|default:"" }}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)