I have a list being passed to my template. However I want to 3rd item to be href`d. If i add the html in the view and pass it to the template it get escaped and displayed as html rather then a link.
Whats the best way to achieve this ?
Thanks,
Use the forloop.counter in your template to conditionally add the href rather than trying to add HTML in the view:
template.html
<ul>
{% for item in mylist %}
<li>
{% if forloop.counter == 3 %}<a href="myhref">{% endif %}{{ item }}{% if forloop.counter == 3 %}</a>{% endif %}
</li>
{% endfor %}
</ul>