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):
7 album = Album.objects.get(slug__exact=slug)
8 photos = Photo.objects.filter(album=album).order_by('order', 'image')
11 return django.views.generic.list_detail.object_list(request, photos, paginate_by=20, template_name='photo/photo_index.html', allow_empty=False)
13 def photo_view(request, slug, id):
16 album = Album.objects.get(slug__exact=slug)
17 photos = Photo.objects.filter(album=album).order_by('order', 'image')
18 photo_qs = Photo.objects.filter(id=id)
25 if not photo.id == id:
36 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 })