I have three models, simplified for the example:
class Customer(models.Model):
email = models.CharField(max_length=128)
class Order(models.Model):
custo
Maybe you don't need this answer now, but if you read the documentation about Sum expression , you need to declare the output_field
, like this:
Customer.objects.filter(something)
.annotate(total_spent=Sum(
F('order__lineitem__quantity') *
F('order__lineitem__price'),
output_field=models.FloatField()
))