First of all, Part.objects.all()[:5] is still lazy. SQL query executes only when you try to iterate through items. And you can slice objects in template with "slice" filter
{% for p in part.object.all|slice:":5" %} On 7 янв, 01:13, "Alexandre Forget" <[EMAIL PROTECTED]> wrote: > Hi, > > I need to limit the number of elements I have to display on an index page. > > Right now I do something like this in the template. > > {% for p in part.object.all %} > ... > {% endfor %} > > Witch obliviously output all objects in the set. > In the view, I can do it this way: > > Part.objects.all()[:5] > > I would like to do this without doing the actual query in the view, am I > missing something ? > > thanks > > Alexandre Forget --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---