On 7/04/2016 10:14 AM, winarto saputro wrote:
hi all....
i'm new in django and mezzanine
i have already create custom model "partners".
i use this {% partner in page.homepage.partners.all %} and it work fine.
but i want to display only 5 data.
anyone have idea how to do that?
thanks....
sorry for my bad english :)
Well, Googling "django limit loop" brought me these two links, so at
least one should hopefully help you:
http://stackoverflow.com/questions/992230/django-for-loop-counter-break
- most upvoted answer suggests using the 'slice' filter in your loop
http://stackoverflow.com/questions/8373964/django-template-for-loop-print-limited-data-using-for-loop
- uses slice in the second answer, but in the 'step' rather than the
'end' parameter.
If you're familiar with Python slices for lists, this should be easy
enough to comprehend, it's just applying it to Django templates.
Hope this helps,
Seeya. Danny.
--
You received this message because you are subscribed to the Google Groups "Mezzanine
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.