Django templates condition check
All,
Can t we 开发者_StackOverflowdo the following in templates
{% if subject.id == selected_id %}
and also cannot we assign variable like {{selected="selected"}}
Thank........
This comparison will work in Django 1.2. For 1.1 you have to use ifequal:
{% ifequal subject.id selected_id %}
For variable assignment you can use with.
{% with selected as 'selected' %}
{% endwith %}
Don't hesitate to read the documentation, it doesn't hurt.
Not as shown. Use the ifequal
and with
template tags instead.
精彩评论