Sunday, 12 February 2023

Adjusting to and back the size of images with javascript and Django query set

My image model stores the dimension of the image:

class Image(Work):
    size_height_cm = models.FloatField(null=True, blank=True)
    size_width_cm = models.FloatField(null=True, blank=True)
    size_depth_cm = models.FloatField(null=True, blank=True)

My queryset search filters for Images in view.py:

works=Image.objects.filter(creator=self.kwargs['pk'])

I render the image on my page like this:


What I would like to do is to create two buttons: Button 1 and Button 2

When I click Button 1, it will resize all of the images to a height of 100px. like this:


When I click on Button 2, I want to revert to my pre-stored image height.

How do I pass all of the height values with javascript when I'm iterating through the template?



from Adjusting to and back the size of images with javascript and Django query set

No comments:

Post a Comment