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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -