Re: get the latest # of objects

2007-04-22 Thread Oliver Charles
Try Entries.objects.order_by('a_field_that_you_want_to_order_by')[:5] Entries.objects is a query set manager, not a query set, so you can't slice that. -- Ollie > hm. I'm trying to do this in a context processor and its not working: > > def entry_latest(request): > from app.entries.models i

Re: get the latest # of objects

2007-04-22 Thread Honza Král
On 4/22/07, drackett <[EMAIL PROTECTED]> wrote: > > hm. I'm trying to do this in a context processor and its not working: > > def entry_latest(request): > from app.entries.models import Entries > return {'entry_latest': Entries.objects[:5]} yeah, you have to slice the queryset: Entries.obje

Re: get the latest # of objects

2007-04-22 Thread drackett
hm. I'm trying to do this in a context processor and its not working: def entry_latest(request): from app.entries.models import Entries return {'entry_latest': Entries.objects[:5]} On Apr 22, 2:35 pm, "Honza Král" <[EMAIL PROTECTED]> wrote: > just slice it: > entry_list[:5] > > just bea

Re: get the latest # of objects

2007-04-22 Thread Honza Král
just slice it: entry_list[:5] just bear in mind that slicing will actually query the database, so you need to do it when working with the data (e.g. not in urls.py when providing parameters for generic views) On 4/22/07, drackett <[EMAIL PROTECTED]> wrote: > > I love the ability to get the latest

get the latest # of objects

2007-04-22 Thread drackett
I love the ability to get the latest object in a collection.. entry_list.latest() and was curious if there is a way to get more than 1 object. For example, if I want the last 5 entries of a blog, is there something like entry_list.latest(5) I know that doesn't work, but is there an easy way to