3π
β
This is the answer that works in my case. π
def delete(self, *args, **kwargs):
# You have to prepare what you need before delete the model
storage, path = self.image.storage, self.image.path
# Delete the model before the file
super(Profile, self).delete(*args, **kwargs)
# Delete the file after the model
storage.delete(path)
It has to be added in Profile class in model.py.
Hope, it will be helpfull! π
π€Johny
Source:stackexchange.com