I want to do the following in my django html page:
{% if myList|length and ifequal myValue 'somestring' %}
blah blah
{% endif %}
but I get the error: Unused 'myValue ' at end of if expression
How can I do an If AND in a template??
How to use if statement in Django template. In a Django template, you have to close the if template tag. You can write the condition in an if template tag. Inside the block, you can write the statements or the HTML code that you want to render if the condition returns a True value.
What does {{ name }} this mean in Django Templates? {{ name }} will be the output. It will be displayed as name in HTML. The name will be replaced with values of Python variable.
Django Template Language (DTL) is the primary way to generate output from a Django application. You can include DTL tags inside any HTML webpage. The basic DTL tag you can include in an HTML webpage is: 1. {% Tag %}
Try this:
{% if myList|length and myValue == 'somestring' %}
blah blah
{% endif %}
Refer django documentation about use of boolean-operators and complex-expressions in django templates.
Should be something like this:
{% if myList|length and myValue == 'somestring' %}
blah blah
{% 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