1 import django.views.generic.list_detail
2 from django.http import Http404
3 from models import Album, Photo
5 def album_view(request, slug):
6 album = Album.objects.get(slug__exact=slug)
7 photos = Photo.objects.filter(album=album).order_by('order', 'image')
8 return django.views.generic.list_detail.object_list(request, photos, paginate_by=20, template_name='photo/photo_index.html')
10 def photo_view(request, slug, id):
12 album = Album.objects.get(slug__exact=slug)
13 photos = Photo.objects.filter(album=album).order_by('order', 'image')
14 photo_qs = Photo.objects.filter(id=id)
21 if not photo.id == id:
30 return django.views.generic.list_detail.object_detail(request, photo_qs, object_id=id, template_name='photo/photo.html', extra_context={"next_photo": next_photo, "prev_photo": prev_photo })