Django aggregation query on related one-to-many objects
- by parxier
Here is my simplified model:
class Item(models.Model):
pass
class TrackingPoint(models.Model):
item = models.ForeignKey(Item)
created = models.DateField()
data = models.IntegerField()
In many parts of my application I need to retrieve a set of Item's and annotate each item with data field from latest TrackingPoint from each item…