I would like to negate the result of a group of conditions separated ors in an if statement in a django template. Heres my code
{% if not (owner.home_number or owner.work_number or owner.mobile_number) %}
No contact number available
{% endif %}
I am currently getting this error
TemplateSyntaxError: Could not parse the remainder: '(owner.home_number' from '(owner.home_number'
Since the order of evaluation is the following:
you can omit the parenthesis:
{% if not owner.home_number or owner.work_number or owner.mobile_number %}
No contact number available
{% endif %}
Or, just FYI, you can also reverse the check:
{% if owner.home_number or owner.work_number or owner.mobile_number %}
{% else %}
No contact number available
{% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With