django-imagekit - do not crash when source file does not exist

87 Views Asked by At

I have a Django model that has an image and an autogenerated thumbnail:

img = ImageField(upload_to=..., max_length=64)
img_thumbnail = ImageSpecField([ResizeToFit(width=64, height=64)], source='img')

For a number of reasons, the img field may contain a filename that is no longer present in the filesystem. When the file is not there, the view crashes with a FileNotFoundError - No such file or directory: '....png'

Is it possible to configure the img_thumbnail field / django-imagekit to fail silently? Also without writing having to catch the exception in the view.

0

There are 0 best solutions below