X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/4f7ac989eb7d803f72eebb5e2eaed4d54322f19a..56fdd60e7a54f19cd9fc10db475688a557ed7df7:/contact/forms.py diff --git a/contact/forms.py b/contact/forms.py index a9e3366..cc60c73 100644 --- a/contact/forms.py +++ b/contact/forms.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import os + from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.core.files.uploadedfile import UploadedFile @@ -141,7 +143,9 @@ class ContactForm(forms.Form): email_changed = True for name, value in self.cleaned_data.items(): if isinstance(value, UploadedFile): - Attachment.objects.filter(contact=contact, tag=name).delete() # delete files? + for attachment in Attachment.objects.filter(contact=contact, tag=name): + os.remove(attachment.file.path) + attachment.delete() attachment = Attachment(contact=contact, tag=name) attachment.file.save(value.name, value) attachment.save()