I have been searching and came across this (Multiple images per Model) which explains how to get all the images for a specific object but how would I load multiple images for a list of 2,000+ objects - I know I could loop and grab all the objects from each image but then how would I display the correct images with the correct objects in the html?
While writing this, I was wondering if this is a good use for template_tags but I am extremely new to them.
Working with these basic cut down models as an example.
class Auction(models.Model):
auction_title = models.CharField(max_length=255, null=True)
class Listing(models.Model):
auction_id = models.ForeignKey(Auction, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
class ListingImage(models.Model):
listing_id = models.ForeignKey(Listing, on_delete=models.CASCADE, related_name='images')
image = models.ImageField()
view example to run off of, expecting anything up to thousands of items returned.
listings = Listing.objects.filter(time_ending__gte=datetime.now()).order_by('time_starting')
so with that example view above how would I go about grabbing each image for each of those listings and then more of an issue was finding the way to display those in html in loops or in any order or specifically chosen. Thank you so much for your help!