X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/f69c55b527dcbf1c578baa95afbac75211249fc2..eeafdfccb63314d85802f3064b6fb904375bda03:/sommitrealweird/photo/views.py diff --git a/sommitrealweird/photo/views.py b/sommitrealweird/photo/views.py index 8501a6f..bddd15d 100644 --- a/sommitrealweird/photo/views.py +++ b/sommitrealweird/photo/views.py @@ -1,6 +1,6 @@ from django.views.generic import ListView, DetailView from django.http import Http404 -from models import Album, Photo +from photo.models import Album, Photo class AlbumListView(ListView): model = Album @@ -10,12 +10,14 @@ class AlbumListView(ListView): class PhotoListView(ListView): model = Photo paginate_by = 20 - order_by = 'order, image' + + def order_by(self): + return self.ordering def get_queryset(self): try: album = Album.objects.get(slug__exact=self.kwargs['slug']) - return Photo.objects.filter(album=album) + return Photo.objects.filter(album=album).order_by('order', 'image') except: raise Http404