I’d like to save thumbnails on request for some fields in one model-class. The pain for me is, how do I manage to keep the thumbnail-class as simple as possible?
Let’s say I’ve got this main-class
class Staff(models.Model):
name = models.CharField(max_length=100)
img1 = models.ImageField(upload_to=upload_path)
img2 = models.ImageField(upload_to=upload_path)
img3 = models.ImageField(upload_to=upload_path)
...
Now I’d like to save a thumbnail for each img-field in another model-class. So I’m able to query against Thumbnail if there is a thumb for e.g. img1…something like this (not working code)
class Thumbnail(models.Model):
staff = models.ForeignKey(Staff)
field = models.FooBar('Staff._meta.fields...')
thumb = models.ImageField(upload_to=upload_path2)
Any suggestions or ideas of how this Thumbnail-class could look like?
I would suggest little more change to the models for better storing image and thumbnail.
You can create
ImageInfomodel that holds original image, thumbnail and any other attributes. It will have foriegnkey withStaffso that you can have multiple images for aStaffNow you can find images which have thumbnail set are