diff --git a/recette/models.py b/recette/models.py index aac7568..feb3468 100644 --- a/recette/models.py +++ b/recette/models.py @@ -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): - os.remove(old_file.path) + if old_file and old_file != instance.photo and os.path.isfile(old_file.path): + os.remove(old_file.path)