python - django print only one value in for loop in template -


i want display 1 value loop in template. let's have this:

{% category in categories %}     {{category.name}}     <a href="{% url "my_url" category.id %}">see all</a> {% endfor %} 

if have 5 category see in being printed 5 times. how can print once.. thanx in adnvance..

you have limit object , send object template

tempalte_var['content'] = categories.objects.all()[:5] 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -