I've been struggling with a problem recently and since I'm not a programmer, I feel like I'm beating my head against a wall. I have a Django app that will act as a photo gallery for photos I've taken over the years and I've organized those photos into albums. I have a page that lists all the pictures from a particular album and a page that allows you to view a single photo from that album. To the left of that photo is a thumbnail of the photo immediately before the current photo and to the right is the photo that comes next. The problem I'm having is targeting the record immediately before the current record. I've been able to successfully target the next record by doing something like this:
slug = <album_slug> photo_id = <photo_id> album = Album.objects.get(slug=slug) next = album.photo_set.filter(id__gt=<photo_id>)[:1] In order to get to the previous I've used the following: prev = album.photo_set.filter(id__lt=<photo_id>)[:1] But alas, this returns the first record encountered that is less than the supplied 'id'. This would inevitably be the first photo in the album. Does anyone have any ideas? Thanks in advance. -Josh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---