From fc4167ffc2d465249f875c18ec1f469db09a395c Mon Sep 17 00:00:00 2001 From: reverend Date: Thu, 30 Jul 2020 22:18:55 +0200 Subject: [PATCH] PlaceImageForm Filename required --- lostplaces/lostplaces_app/forms.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lostplaces/lostplaces_app/forms.py b/lostplaces/lostplaces_app/forms.py index b0306c9..38120ed 100644 --- a/lostplaces/lostplaces_app/forms.py +++ b/lostplaces/lostplaces_app/forms.py @@ -25,5 +25,10 @@ class PlaceImageCreateForm(forms.ModelForm): fields = '__all__' exclude = ['submitted_by', 'place', 'description'] widgets = { - 'filename': forms.ClearableFileInput(attrs={'multiple': True}) - } + 'filename': forms.ClearableFileInput(attrs={'multiple': True}), + }, + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + print(self.fields) + self.fields['filename'].required = False