class Price(models.Model):
date = models.DateField()
price = models.DecimalField(max_digits=6, decimal_places=2)
product = models.ForeignKey("Product")
class Product(models.Model):
name = models.CharField(max_length=256)
price_history = models.ManyToManyField(Price, related_name="product_price", blank=True)
我想查询产品,以便仅返回那些日期x的价格高于任何较早日期的产品。根据ForeignKey子元素之间的关系查询Django模型
谢谢boffins。