def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) votes_filter = PartyVotesFilter(self.request.GET, queryset=PartyVoteBehaviour.objects.all()) n_votes_total = 0 stats = [] parties = PoliticalParty.sort_by_current_seats(PoliticalParty.objects.all()) for party in parties: stat = PartyVoteBehaviour.get_stats_party_for_qs(party, votes_filter.qs) stats.append(stat) n_votes_total += stat['n_votes'] context['stats'] = stats context['n_votes'] = n_votes_total context['filter'] = votes_filter context['page_stats_votings_parties'] = True return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) parties = PoliticalParty.objects.exclude(slug__exact='') parties = PoliticalParty.sort_by_current_seats(parties) context['parties'] = parties return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) parties = PoliticalParty.objects.all() parties = PoliticalParty.sort_by_current_seats(parties) context['parties'] = parties return context