From a666a3fea454140159c3c9d08f1b3e50f18dccb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 3 Jan 2023 19:04:45 +0100 Subject: [PATCH] =?UTF-8?q?hotfix:=20nemohl=20odevzd=C3=A1vat=20=C5=99e?= =?UTF-8?q?=C5=A1itel=20samotn=C3=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odevzdavatko/forms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index a31122dd..223d807f 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -82,6 +82,13 @@ class NahrajReseniForm(forms.ModelForm): ) } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # FIXME Z nějakého důvodu se do této třídy dostaneme i bez resitele + if 'resitele' in self.fields: + # FIXME Mnohem hezčí by to bylo u definice resitele výše, ale nepodařilo se mi to. + self.fields['resitele'].required = False + ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni, form = NahrajReseniForm, fields = ('soubor','res_poznamka'),