From 11b57bce5544856283d78cb53d8ca277b68b3e0a Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 5 May 2016 11:10:03 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20mais=20um=20'guarda'=20pra=20preserv?= =?UTF-8?q?ar=20ordem=20decrescente=20de=20filia=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parlamentares/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parlamentares/views.py b/parlamentares/views.py index 49efccd9d..50859c56c 100644 --- a/parlamentares/views.py +++ b/parlamentares/views.py @@ -41,6 +41,9 @@ class FiliacaoCrud(MasterDetailCrud): class UpdateView(MasterDetailCrud.UpdateView): form_class = FiliacaoForm + class ListView(MasterDetailCrud.ListView): + ordering = '-data' + class ParlamentarCrud(Crud): model = Parlamentar @@ -79,7 +82,8 @@ class ParlamentarCrud(Crud): def get_rows(self, object_list): parlamentares = [] for m in object_list: - ultima_filiacao = m.parlamentar.filiacao_set.first() + ultima_filiacao = m.parlamentar.filiacao_set.\ + order_by('-data').first() if ultima_filiacao and not ultima_filiacao.data_desfiliacao: partido = ultima_filiacao.partido.sigla else: