> > lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0] > lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id) > lImagesInAlbum = lAlbumImages.count() > lImagePosition = None > lPreviousImage = None > lNextImage = None > for lPosition in range(lImagesInAlbum): > lEachImage = lAlbumImages[lPosition] > if lEachImage.id == lImage.id: > lImagePosition = lPosition + 1 > if lPosition > 0: > lPreviousImage = lAlbumImages[lPosition-1] > if lPosition < lImagesInAlbum-1: > lNextImage = lAlbumImages[lPosition+1] > break >
Pagination might be what you're looking for: http://www.djangoproject.com/documentation/pagination/ Colin > > > On Saturday 29 Mar 2008, Tim Sawyer wrote: > > Hi Folks, > > > > If I have an image, and a list of images, how can I work out what position > > in the list my image is so I can do a Image 4 of 24 type annotation? > > > > lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0] > > lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id) > > lImagesInAlbum = lAlbumImages.count() > > lImagePosition = ??? > > > > My view is passed pImageSerial which is the id of the image to display. I > > can work out the Image object from this. I can also get the full list of > > images for this particular album, and work out how many images there are in > > total. The images are ordered by filename, so I know the order will be > > consistent. > > > > How do I work out lImagePosition? Can anyone give me any pointers? > > > > Thanks, > > > > Tim. > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---