Django lets you follow relations link, but none of the filter methods let you get youngest/oldest, or max/min, afaik.
Laravel has "has one of many", and I wish that Django had something similar without requiring window functions, that have their own limitations.
Annotations despite being promising, are also a dead end.
Therefore I wonder what the best design is for the following situation:
I have "model A", whose instances will pass through several statuses during their lifecycle ("created", "processing", "complete"). I want to know what status an instance of model A currently has, but also have a record of when each status was in effect. I don't want to parse logs.
I thought a good approach was to create a status model (model B) whose foreign key is a model A instance. it becomes easy to see when each status was started and stopped.
However if I want to get the current status (an instance of model B) for all my model A instances, I need to do n+1 database queries. This seems sub-optimal.
What are some alternatives?