In my django template I have
{% if object_not_readonly and user_is_worker or user_is_admin %}
Django doc tell me
Use of both and and or clauses within the same tag is allowed, with and having higher precedence than or
I think this is not obvious way to declare logical precedence in IF clause.
Question is:
Is it something like {% if object_not_readonly and ( user_is_worker or user_is_admin ) %}
condition in django template language, with obvious clause like if A and (C or B) and (not Z)
?
It's not clear what you're asking here, or what result you are trying to achieve with your example statement:
{% if object_not_readonly and user_is_worker or user_is_admin %}
To clarify what they mean in the reference docs by "Use of both and and or clauses within the same tag is allowed, with and having higher precedence than or", the above statement would be evaluated as:
{% if (object_not_readonly and user_is_worker) or user_is_admin %}
which is not the same as {% if object_not_readonly and ( user_is_worker or user_is_admin ) %}
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