Resolve ambiguity in Work lists order -- sort by Work.id as a secondary sort key

pull/1/head
Raymond Yee 2012-02-01 09:43:46 -08:00
parent 17c8de9473
commit fb77d1a08d
1 changed files with 3 additions and 3 deletions

View File

@ -201,13 +201,13 @@ class WorkListView(ListView):
def get_queryset(self): def get_queryset(self):
facet = self.kwargs['facet'] facet = self.kwargs['facet']
if (facet == 'popular'): if (facet == 'popular'):
return models.Work.objects.filter(wishlists__isnull=False).distinct().annotate(wished=Count('wishlists')).order_by('-wished') return models.Work.objects.filter(wishlists__isnull=False).distinct().annotate(wished=Count('wishlists')).order_by('-wished', 'id')
elif (facet == 'recommended'): elif (facet == 'recommended'):
return models.Work.objects.filter(wishlists__user=recommended_user) return models.Work.objects.filter(wishlists__user=recommended_user)
elif (facet == 'new'): elif (facet == 'new'):
return models.Work.objects.filter(wishlists__isnull=False).distinct().order_by('-created') return models.Work.objects.filter(wishlists__isnull=False).distinct().order_by('-created', 'id')
else: else:
return models.Work.objects.all().order_by('-created') return models.Work.objects.all().order_by('-created', 'id')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(WorkListView, self).get_context_data(**kwargs) context = super(WorkListView, self).get_context_data(**kwargs)