From 075239c730821f8acd231cd25987bb1c16031421 Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Mon, 8 Jun 2020 14:18:43 +0100 Subject: [PATCH 1/1] Fix photo ordering --- sommitrealweird/photo/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 -- 2.39.5