Brilliant, thanks for that. As an aside, if anyone ends up finding this thread looking for a similar solution try looking here: http://www.djangobook.com/en/1.0/appendixC/
There is lots of good stuff there. I had looked in the djangobook but spent a lot of time reading the model section thinking the answer would be there if anywhere. I skimmed the database api stuff but obviously did not pay enough attention!. On Apr 5, 10:26 pm, 1234 <[EMAIL PROTECTED]> wrote: > *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 -~----------~----~----~----~------~----~------~--~---