Django stringformat i -
i have dropdown list on page. when user selects value, index of option stored in database. when user retrieves page, previous stored value should selected default.
this how render selected option in template:
{% if report.tag == forloop.counter|stringformat:"i" %} selected="selected" {% endif %} the loop contains list of values, report.tag contains value selected user.
my question is: when comparing values in template have use forloop.counter|stringformat:"i". if forloop.counter used, comparison not work. why that?
// if never registers, though foorloop.counter // outputs same value forloop.counter|stringformat:"i" {% if report.tag == forloop.counter %}
Comments
Post a Comment