Fix error in auto_delete_photo_on_change

This commit is contained in:
Claude Paroz 2018-06-01 20:36:23 +02:00
parent 27947907d5
commit 0a98e4a778

View file

@ -96,7 +96,5 @@ def auto_delete_photo_on_change(sender, instance, **kwargs):
except Recette.DoesNotExist:
return False
new_file = instance.photo
if not old_file == new_file:
if os.path.isfile(old_file.path):
if old_file and old_file != instance.photo and os.path.isfile(old_file.path):
os.remove(old_file.path)