From 3509a8cf21b7eabf2d18d680c47b28f526863b43 Mon Sep 17 00:00:00 2001 From: Victor Fabre Date: Mon, 25 Mar 2019 14:51:13 -0300 Subject: [PATCH] =?UTF-8?q?Melhora=20constru=C3=A7=C3=A3o=20de=20not=5Flis?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/views.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 6ec1a9785..696b1235a 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -2085,10 +2085,9 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView): qr = self.request.GET.copy() context['object_list'] = context['object_list'].order_by( 'ano', 'numero') - not_list = [self.kwargs['pk']] principal = MateriaLegislativa.objects.get(pk=self.kwargs['pk']) - for m in principal.materia_principal_set.all(): - not_list.append(m.materia_anexada.id) + not_list = [self.kwargs['pk']] + \ + [m for m in principal.materia_principal_set.all().values_list('materia_anexada_id', flat=True)] context['object_list'] = context['object_list'].exclude(pk__in=not_list) context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''