@ -64,6 +64,13 @@ class NormaPesquisaView(FilterView):
filterset_class = NormaFilterSet
paginate_by = 10
def get_queryset(self):
qs = super().get_queryset()
qs.select_related('tipo', 'materia')
return qs
def get_context_data(self, **kwargs):
context = super(NormaPesquisaView, self).get_context_data(**kwargs)
@ -2429,7 +2429,8 @@ class PesquisarSessaoPlenariaView(FilterView):
kwargs = {'data': self.request.GET or None}
qs = self.get_queryset()
qs = self.get_queryset().select_related(
'tipo', 'sessao_legislativa', 'legislatura')
qs = qs.distinct().order_by(
'-legislatura__numero', '-data_inicio', '-numero')