jdriscoll/django-imagekit — Issue #109: PessimisticCache doesn't seem to work
Author: volksman
Created: 2012-02-22 19:19:55+00:00
State: open

Hello! Long time imagekit user but first time using the new flavor. I setup a model:

class EmployeeProfile(BaseProfile):
position = models.ForeignKey(Position, verbose_name=_('position'))
employee_image = models.ImageField(upload_to=get_employee_image_path,
blank=True, null=True)
avatar = ImageSpec([resize.ResizeToFit(100, 100)], image_field='employee_image',
format='JPEG')
profile_pic = ImageSpec([resize.ResizeToFit(300, 300)], image_field='employee_image',
format='JPEG')

Then in my view where I allow the user to upload an image:

if profile_form.is_valid():
m = profile_form.save()

Which I would expect to save the image and pre_cache the 2 sizes. However this doesn't work. When I then call the image_obj.url I get an IO error stating that the file doesn't exist. The only way I've found to fix it is to call the URL function in the view first, so add this line to the above:

m.signature_img.url

And suddenly my template will render with the cached image. I've read about the new cache backends and from what I can tell the pessimistic backend is default. So what am I doing wrong?

Thanks for any pointers.