Fix problème lors de l'édition de version sans image

This commit is contained in:
Jean-Marie Favreau 2024-11-10 21:37:56 +01:00
parent daf4ab1eeb
commit b1dcd55ebc

View File

@ -154,7 +154,9 @@ class EventForm(ModelForm):
super().clean()
# when cloning an existing event, we need to copy the local image
if self.cleaned_data['local_image'] is None and not self.cleaned_data['old_local_image'] is None:
if self.cleaned_data['local_image'] is None and \
not self.cleaned_data['old_local_image'] is None and \
self.cleaned_data['old_local_image'] != "":
basename = self.cleaned_data['old_local_image']
old = settings.MEDIA_ROOT + "/" + basename
self.cleaned_data['local_image'] = File(name=basename, file=open(old, "rb"))