This commit is contained in:
2025-08-31 00:29:53 +02:00
parent 191bd84573
commit 29611b15ca
87 changed files with 2451 additions and 0 deletions

26
app/upload/forms.py Normal file
View File

@@ -0,0 +1,26 @@
from django import forms
from .models import Upload, Image
class UploadImageForm(forms.ModelForm):
class Meta:
model = Image
fields = ['file']
def save(self, commit=True):
image = super().save(commit=False)
if not image.name:
image.name = image.file.name
if not image.content_type:
from utils import get_mimetype
image.content_type = get_mimetype(image.file)
image.size = image.file.size
if commit:
image.save()
return image