views:

40

answers:

2

In my template I have this for loop:

                    {% for member in blog.members.all %}
                         {{ member.first_name }}
                    {% endfor %}

Is there a way to retrieve only the first 10 members and not all the members ?

+4  A: 

For full-scale paging, check out django-pagination. For simple slicing, check out the slice filter.

Hank Gay
+2  A: 
{% for member in blog.members.all|slice:"10" %}
   {{ member.first_name }}
{% endfor %}
eos87