*get next* = Info.objects.filter(id__gt=newsid).order_by('id')[:1]

*get last* = Info.objects.filter(id__lt=newsid).order_by('id')[:1]



2008/4/5, SlowLearner <[EMAIL PROTECTED]>:
>
>
> Hi, I am hoping there is a better solution to my problem than the one
> I have come up with, or one built in to the django models.
>
> I would like to include "get next" and "get last" buttons on my view.
>
> The catch is that I want to do get next, get last on an integer field
> (which is not a primary key but is unique, if that make a difference).
>
> Searching in the group and googling the internet in general turns up a
> few things but these are date based or quite old posts suggesting
> creating managers etc.
>
> My current solution is a brute force cycle over all the objects until
> I find the object wanted, the previous and the next which is not ideal
> but works.
>
> I am currently using 0.96 but I am intending to download trunk in the
> not too distant future as there is a templatetag application I want to
> use which does not work under 0.96.
>
> Thanks in advance.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to