From: Brett Parker Date: Mon, 8 Jun 2020 13:18:43 +0000 (+0100) Subject: Fix photo ordering X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/075239c730821f8acd231cd25987bb1c16031421?ds=sidebyside Fix photo ordering --- diff --git a/sommitrealweird/photo/views.py b/sommitrealweird/photo/views.py index fea7dd3..bddd15d 100644 --- a/sommitrealweird/photo/views.py +++ b/sommitrealweird/photo/views.py @@ -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