How to delete cache and original image?

227 views
Skip to first unread message

David Tan

unread,
Mar 5, 2016, 6:32:47 PM3/5/16
to Django ImageKit
In 2013, matthewwithanm posted that "There's currently not a great way to do this" so I'm wondering if anything has changed since then. I posted in this issue as well, but no response yet: https://github.com/matthewwithanm/django-imagekit/issues/229

I would like to find something to delete the cache files and the original image file when the image is deleted. I've seen snippets from other users use signals, so this is what I'm trying. What should the real version of delete_all_created_images() and delete_original_image() be? Thanks

@receiver(models.signals.post_delete, sender=Image)
def delete_image(sender, instance, **kwargs):
 instance
.image.delete_all_created_images()
 instance
.image.delete_original_image()
Reply all
Reply to author
Forward
0 new messages