Skip to content

Instantly share code, notes, and snippets.

@gregnewman
Created August 19, 2011 10:53
Show Gist options
  • Save gregnewman/1156570 to your computer and use it in GitHub Desktop.
Save gregnewman/1156570 to your computer and use it in GitHub Desktop.
Example for Imagekit
class Book(models.Model):
title = models.CharField(max_length=200)
class Page(ImageModel):
book = models.ForeignKey(Book)
image = models.ImageField(upload_to='book_photos')
num_views = models.PositiveIntegerField(editable=False, default=0)
class IKOptions:
# This inner class to define the ImageKit options for the model
spec_module = 'books.image_specs'
cache_dir = 'book_photos'
image_field = 'image'
save_count_as = 'num_views'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment