dossier_list.py 450 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# coding: utf-8

from core.views import PaginationMixin

from django.db.models import Count
from django.views import generic

from representatives_votes.models import Dossier


class DossierList(PaginationMixin, generic.ListView):

    queryset = Dossier.objects.prefetch_related(
        'proposals',
        'proposals__recommendation'
    ).annotate(
        nb_recomm=Count('proposals__recommendation')
    ).order_by('-nb_recomm', '-reference')