From d4c878b22d259956edd82e1558cd477c3eaa57d0 Mon Sep 17 00:00:00 2001 From: Tomas Jethro Pokorny Date: Sat, 18 Feb 2017 15:56:01 +0100 Subject: [PATCH] Zrychleni nacitani seznamu prednasek. --- prednasky/admin.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/prednasky/admin.py b/prednasky/admin.py index a1d0e63c..f09310a0 100644 --- a/prednasky/admin.py +++ b/prednasky/admin.py @@ -10,17 +10,24 @@ from models import Prednaska, Seznam, STAV_NAVRH from seminar.models import Soustredeni class Seznam_PrednaskaInline(admin.TabularInline): -# form = autocomplete_light.modelform_factory(Prednaska, autocomplete_fields=['nazev'], fields=['nazev']) model = Prednaska.seznamy.through -# fields = ['nazev', 'org', 'obor' ] -# extra = 0 -# formfield_overrides = { -# models.TextField: {'widget': forms.TextInput}, -# } - -# def get_queryset(self, request): -# qs = super(Seznam_PrednaskaInline, self).get_queryset(request) -# return qs.select_related('seznam', 'prednaska') + fields = ('nazev','obor','org') + readonly_fields = ('nazev','obor','org') + can_delete = True + + def nazev(self,obj): + print self,obj + return obj.prednaska.nazev + def obor(self,obj): + print self,obj + return obj.prednaska.obor + def org(self,obj): + print self,obj + return obj.prednaska.org + + def get_queryset(self, request): + qs = super(Seznam_PrednaskaInline, self).get_queryset(request) + return qs.select_related('prednaska', 'prednaska__org') class SeznamAdmin(VersionAdmin): list_display = ['soustredeni','stav']