Hi! I'm trying to use ImageKit but I can't find a way of having empty fields. I can't find any options for it.
My code:
class ImageMedium(ImageSpec):
format = 'JPEG'
options = {'quality': 80}
@property
def processors(self):
model, field_name = get_field_info(self.source)
return [ResizeToFill(
model.image_width / 2,
model.image_height / 2)]
register.generator('api:bookmark:image_medium', ImageMedium)
class ImageSmall(ImageSpec):
format = 'JPEG'
options = {'quality': 80}
@property
def processors(self):
model, field_name = get_field_info(self.source)
return [ResizeToFill(
model.image_width / 4,
model.image_height / 4)]
register.generator('api:bookmark:image_small', ImageSmall)
class Bookmark(models.Model):
image = models.ImageField(upload_to=get_image_path,
height_field='image_height',
width_field='image_width',
null=True, blank=True,
max_length=767)
image_height = models.PositiveIntegerField(default=0)
image_width = models.PositiveIntegerField(default=0)
# Thumbnail generation fields
image_medium = ImageSpecField(source="image",
id='api:bookmark:image_medium')
image_small = ImageSpecField(source="image",
id='api:bookmark:image_small')
When I request a list of bookmarks, I get:
MissingSource at /api/bookmarks/
The spec '<api.models.ImageMedium object at 0x7f2b947fd8d0>' has no source file associated with it.
Thanks in advance for the help,
Rodrigo