About ANDs and ORs in Django Templates
ANDs precede ORs in the conditions of most programming languages. So these following two lines are equivalent in Python:
1 2 |
|
Django template language doesn't have a concept of parentheses in conditions, so the above condition would look like this:
1 2 3 |
|
To have ORs executed before ANDs in Django templates, use nesting:
1 2 3 4 5 |
|
Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2 Python 3