I am working on a project which contains a Model with 'product name', 'picture' and 'picture_thumbnail'. Where second one is ImageField and thumbnail one is ImageSpecField.
'.
class ProductImage(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE)
owner = models.ForeignKey(User,
on_delete=models.CASCADE)
picture = models.ImageField(
upload_to=get_uploaded_file_name,
blank=
True,
null=
True)
picture_thumbnail = ImageSpecField(source='picture',
processors=[ResizeToFill(200, 150)],
format='JPEG',
options={'quality': 60})
Now I can easily get the thumbnail in Django template like -
{{ object.picture_thumbnail.url }}
What do I want to know is - how to get picture object corresponding to
picture_thumbnail. Actually I want to show all thumbnail list, related to the Product and by clicking on the thumbnail, I want to get the original
picture which is the source of that thumbnail.
Is there any way to get it? May be directly or indirectly(like by creating similar name, I don't know how)?
Thanks in advance