You could setup property on your model that would return "previous"
and "next" values in form you would like.
http://www.djangoproject.com/documentation/models/properties/
On Apr 1, 12:45 am, x13 wrote:
> Hello,
>
> I'm trying to figure out a simple way to get a known record from a
> database but
I know how to do this with 3 queries:
object = Model.objects.filter(pk=pk)
previous =
Model.objects.filter(votes__lt=object.votes).order_by('-votes')[:1][0]
next = Model.objects.filter(votes__gt=object.votes).order_by('votes')[:1][0]
My only problem with this is if there is any object with the sa
Hello,
I'm trying to figure out a simple way to get a known record from a
database but also get the "previous" and "next" records too. My model
is a Photo table with user's votes :
ID Votes
1 24
2 5
3 102
4 21
5 10
So, if I query for the photo with ID=4 (21 votes) I'd like
3 matches
Mail list logo