You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the version.previous attribute is calling VersionObjectFetcher.previous
Which runs: self.previous_query(obj).first()
Because it is using .first() - a query is running every time.
It would be a nice developer experience to cache this so it does not call multiple queries.
Currently I need to do:
current = ...
previous = current.previous
And then pass it all around in my functions to avoid performance issues.
It would make my code a lot simpler if the previous property cached the value so I did not need to save it in my own separate variable
Added in 1.6.0 (#376): ArticleVersion.all_versions(session, {'id': article.id}) loads the whole history in one query and pre-fills previous/next, so walking it doesn't run extra queries. See the batch-fetching section of the query docs.
Activity
josecsotomorales commentedon Oct 15, 2026
Added in 1.6.0 (#376):
ArticleVersion.all_versions(session, {'id': article.id})loads the whole history in one query and pre-fillsprevious/next, so walking it doesn't run extra queries. See the batch-fetching section of the query docs.