From 2b1ec584be7d13aac4d1c8b2184068ba49904b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Sun, 26 Mar 2017 20:34:03 +0200 Subject: [PATCH] =?UTF-8?q?Admin:=20nezobrazuj=20po=C4=8Det=20=C5=99e?= =?UTF-8?q?=C5=A1en=C3=AD=20u=20zadan=C3=BDch=20probl=C3=A9m=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zrychlení načítání cca 25 s -> 1 s --- seminar/admin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index d9771f5e..82df8fff 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -445,9 +445,12 @@ class ProblemNavrhAdmin(ProblemAdmin): create_modeladmin(ProblemNavrhAdmin, Problem, 'ProblemNavrh', verbose_name=u'Problém (návrh)', verbose_name_plural=u'Problémy (návrhy)') + class ProblemZadanyAdmin(ProblemAdmin): - list_display = ['nazev', 'typ', 'autor', 'opravovatel', 'kod', 'cislo_zadani', 'pocet_reseni', 'verejne'] - list_filter = ['typ', 'zamereni', 'cislo_zadani__cislo', 'cislo_zadani__rocnik'] + list_display = ['nazev', 'typ', 'autor', 'opravovatel', 'kod', 'verejne'] + list_filter = [ + 'typ', 'zamereni', 'cislo_zadani__cislo', 'cislo_zadani__rocnik' + ] def get_inline_instances(self, request, obj=None): if obj and obj.typ == Problem.TYP_ULOHA: @@ -459,7 +462,7 @@ class ProblemZadanyAdmin(ProblemAdmin): def get_queryset(self, request): qs = super(ProblemZadanyAdmin, self).get_queryset(request) - return qs.filter(stav=Problem.STAV_ZADANY).annotate(pocet_reseni=Count('reseni')) + return qs.filter(stav=Problem.STAV_ZADANY) get_form = get_form_predvypln_autora