summaryrefslogtreecommitdiff
path: root/app/sightings/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/sightings/views.py')
-rw-r--r--app/sightings/views.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/sightings/views.py b/app/sightings/views.py
index c4aab46..6f536b6 100644
--- a/app/sightings/views.py
+++ b/app/sightings/views.py
@@ -4,6 +4,7 @@ from django.contrib.auth.models import User
from django.utils import timezone
from utils.views import PaginatedListView,LuxDetailView
from .models import AP, Sighting, FieldNote
+from django.db.models import Subquery
class SightingListView(PaginatedListView):
@@ -47,7 +48,12 @@ class YearListView(ListView):
template_name = 'sightings/year-list.html'
def get_queryset(self):
- return Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap__id').distinct('ap')
+ qs = Sighting.objects.filter(
+ pk__in=Subquery(
+ Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap_id').distinct('ap').values('pk')
+ )
+ ).order_by('-pub_date')
+ return qs #Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap__id','pub_date').distinct('ap')
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context