I am using ImageKit (great!)
model.py
from imagekit.models import ImageModel class Photo(ImageModel): name = models.CharField(max_length=100) original_image = models.ImageField(upload_to='photos') num_views = models.PositiveIntegerField(editable=False, default=0) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') class IKOptions:
specs.py
from imagekit.specs import ImageSpec from imagekit import processors from imagekit.lib import *
in your template you will get access to the following thumbnails:
{% for p in vehicle.images.all %} {{ p.get_thumbnail.url }} {% endfor %}
admin.py might look like this:
class ImagesInline(generic.GenericTabularInline): model = Photo max_num =4 class VehicleAdmin(admin.ModelAdmin): inlines = [ImagesInline]
About user ImageKit
add the specs.py file to your application and tell ImageKit about it like this
class IKOptions:
add a field to your photo model to save what kind / content it displays. i.e. ChoiceField
In the view / template you can filter it
source share