Hi Guys,
I know django purposely does not allow a whole lot of logic in the templates. However sometimes you are required to evaluate something and based on that change your options.
How do you change a value in a template or insert something only if it's the first record? But you would still like to loop through the rest. For example, my template code below:
{% for object in object_list %}
<div id="t{{ object.id }}-header" class="content_headings title_highlight" >{{ object.title }}</div>
<div id="t{{ object.id }}-content">
......
Similar code in a PHP template:
<div id="t<?php if ($i != 1) { echo $i-1; } ?>-header" class="content_headings<?php if ($i == 1) { ?> title_highlight<?php } ?>" ><?php the_title(); ?></div>
<div id="t<?php if ($i != 1) { echo $i-1; } ?>-content">