My simplified models:
class Product(models.Model):
name = models.CharField()
class Price(models.Model):
product = models.OneToOneField('Product', primary_key=True)
value = models.DecimalField()
class Cart(models.Model):
product = models.ForeignKey('Product')
qnt = models.IntegerField()
I need multiplication of two fields get stored in other field namely sum
. Why does Cart.objects.select_related('product__price').annotate(sum=F('product__price__value') * F('qnt'))
returns nothing?
Replacing F('')
to F('value')
returns error
Cannot resolve keyword 'value' into field. Choices are: cart_id, id, product, product_id, qnt