I'm using Imagekit to resize pictures on a website i'm developing with Django, I've used Imagekit before without any issues but I have a strange problem.
I am using S3 for Media/Static files. When I upload an image in admin and refresh the template serving the images i get ValueError at / I/O operation on closed file error page. Then if I refresh the page it loads fine without a problem.
I am using an ImageSpec field to resize images and using {{ image.thumbnail.url }} in my template.
I am very much a beginner with Django so looking for some direction. Why will it work on a page reload and not when initially uploaded?
Here are the relevant fields in my model.
class Media(models.Model):
image = models.ImageField(upload_to="media")
thumbnail = ImageSpecField([Adjust(sharpness=1.1), ResizeToFill(800, 650)],
source='image', format='JPEG', options={'quality': 100})
I am assuming it's a problem with S3. It's trying to access the resized image but the Imagekit thumbnail isn't created on fileupload, only when the page is loaded?
Ok, after some searching, this is the fix (and all now working) to solve the issue with storages which is the source of the problem.