I don't know of a way to do this by a calculated fraction of the total
items in the list, but you can use the slice filter to break it up
into groups of a set number:

{% for object in object_list|slice:":5" %}

{% for object in object_list|slice:"5:10" %}

etc.

There's also a handy trick if you want to insert something (a break
for instance) between groups in a list, say ever third item.

{% if forloop.counter|divisibleby:"3" %}<br />{% endif %}

On 6/17/06, James Stembridge <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Is there a way to split a list using the built-in tags and filters?
> What I want is to take an object list from a generic view and iterate
> over the first and second halfs separetely. e.g.
>
> {% for object in object_list|firsthalf %}
> ...
> {% endfor %}
>
> {% for object in object_list|secondhalf %}
> ...
> {% endfor %}
>
> Of course it doesn't necesserily have to be halfs, could be thirds,
> quarters, etc.
>
> Cheers,
> James.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to