开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜