Reputation: 577
In the following model:
class Product(models.Model):
name = models.CharField(max_length = 255)
created_in = models.DateTimeField(auto_now=True)
class Price(models.Model):
product = models.ForeignKey(Product)
price = models.DecimalField(max_digits=6, decimal_places=2)
created_in = models.DateTimeField(auto_now=True)
I want to do things like this:
products = Product.objects.filter(price__gte=Decimal(10)) #It considered all prices I just need the last one
How do i query a product considering only the last price "created_in" related?
Thanks!!
Upvotes: 1
Views: 1440