Here's my model:
class Product:
name = models.CharField(max_length=80)
price = models.FloatField()
category = models.CharField(max_length=40)
class ProductInventory:
inventory = models.IntegerField()
product = models.OneToOneField(Product, on_delete=models.RESTRICT)
and here's raw sql of what I want to achieve but how do I write this in django ORM?
SELECT product.category, SUM(price) * SUM(product_inventory.inventory)
FROM product LEFT JOIN product_inventory
ON product.id=product_inventory.product_id group by product.category;
Thank you.