How to break "for loop" in Django template
You can't use break statement but you can choose not to print them on html. It's not a best solution but you can use it. I use the following one;
{%for tumbnail in image %}
{%if tumbnail.object_id == element.id %}
<img src="/media/{{ tumbnail.image }}" class="tr_all_hover"alt="">
{{ "<!--" }}
{%endif%}
{%endfor%}
{{ "-->" }}
Its basicly seem like this on browser. http://i.stack.imgur.com/MPbR3.jpg
There is no break
in Django template system. Django template system is not programmed with python but with its own language.
Depending on what you need to do, you might find this question useful. Otherwise, just put the one and only account you are trying to print on HTML on a special field on your RequestContext
.
I think you should use slice to achieve your goal
{% for account in object_list|slice:":1" %}