Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- products = Product.objects.filter(available=True).prefetch_related('images')
- class ProductImage(models.Model):
- image = models.ImageField(upload_to='products/%Y/%m/%d/', blank=True)
- product = models.ForeignKey(Product, related_name='images', on_delete=models.CASCADE)
- {{product.images.first.image.url}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement