1 from django.views.generic import ListView
2 from django.http import Http404
3 from models import Album, Photo
5 class AlbumListView(ListView):
7 queryset = Album.objects.order_by('-name')
10 def get_context_data(self, **kwargs):
11 context = super(AlbumListView, self).get_context_data(**kwargs)
14 def album_view(request, slug):
16 album = Album.objects.get(slug__exact=slug)
17 photos = Photo.objects.filter(album=album).order_by('order', 'image')
20 return django.views.generic.list_detail.object_list(request, photos, paginate_by=20, template_name='photo/photo_index.html', allow_empty=False)
22 def photo_view(request, slug, id):
25 album = Album.objects.get(slug__exact=slug)
26 photos = Photo.objects.filter(album=album).order_by('order', 'image')
27 photo_qs = Photo.objects.filter(id=id)
34 if not photo.id == id:
45 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 })