I am running the following command to filter out empty values in my template:
{{ product.error_value1|default_if_none:"--" }}
This works well for Null Values but doesn't work if the value entered is "0". I wish the command 'default_if_null' existed. This way it would only check for null.
Any suggestions on an alternative?
CodePudding user response:
If what you mean is you want things like "", [], 0, {}, etc to return True, you can use:
if not bool(x):
Or just simply:
if not x: