Update file forms.py

This commit is contained in:
parping 2024-11-19 11:10:34 +01:00
parent 88fd7a1ec0
commit 43168e253a

View file

@ -16,8 +16,9 @@ from .models import Gallery, Tag
class MultipleFileInput(forms.ClearableFileInput): class MultipleFileInput(forms.ClearableFileInput):
allow_multiple_selected = True allow_multiple_selected = True
class MultipleFileField(forms.FileField): class MultipleFileField(forms.FileField):
allowed_extensions = ['jpg', 'jpeg', 'png','gif', 'tiff'] # Specify allowed extensions here allowed_extensions = ['jpg', 'jpeg', 'png', 'gif', 'tiff'] # Specify allowed extensions here
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
kwargs.setdefault( kwargs.setdefault(
@ -53,8 +54,6 @@ class MultipleFileField(forms.FileField):
) )
return cleaned_file return cleaned_file
class UploadForm(forms.Form): class UploadForm(forms.Form):
file_field = MultipleFileField(label="") file_field = MultipleFileField(label="")
gallery = forms.ModelChoiceField( gallery = forms.ModelChoiceField(