From 8f4bbcbc391f318adb6eca5c538add126811feee Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sun, 27 May 2018 16:24:35 -0500 Subject: fixed a bug in sightings builder --- app/sightings/build.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'app/sightings') diff --git a/app/sightings/build.py b/app/sightings/build.py index 14b363c..9ba758f 100644 --- a/app/sightings/build.py +++ b/app/sightings/build.py @@ -1,5 +1,6 @@ from django.urls import reverse from builder.base import BuildNew +from .models import Sighting class BuildSightings(BuildNew): @@ -8,18 +9,13 @@ class BuildSightings(BuildNew): self.build_detail_view() self.build_list_view( base_path=reverse("sightings:list"), - paginate_by=24 + paginate_by=18 ) - # for user in users: - # if Sighting.objects.filter(seen_by=user): - # self.build_list_view( - # base_path=reverse("sightings:list_by_person", kwargs={'user': user, 'page':1}), - # paginate_by=24 - # ) - # print("building sightings") def get_model_queryset(self): - return self.model.objects.all() + qs_ids = Sighting.objects.order_by('ap__id', '-pub_date').distinct('ap').values_list('id', flat=True) + qs = Sighting.objects.filter(id__in=qs_ids).order_by('-pub_date') + return qs def builder(): -- cgit v1.2.3-70-g09d2