models.py
class Products(models.Model):
name = models.CharField()
price = models.IntegerField()
class Products_Images(models.Model):
products = models.ForeignKey(Products)
image = models.ImageField()
name = models.CharField()
I need to get PRODUCTS and only ONE or NO image for each product.
Like this:
SELECT Products.*,Products_Images.* FROM Products
LEFT JOIN Products_Images on Products.id=Products_Images.product_id AND Products_Images.name LIKE '%pizza%'
WHERE Products.price >= 50