如何获取django-simple-history中最后更改的对象?

问题描述:

使用django-simple-history,如何从模型中获取最后一个更改的对象?如何获取django-simple-history中最后更改的对象?

我试过MyModel.history.most_recent(),它需要一个模型实例,以便返回可能是所选实例的最新版本。

我可以查询Abonnent.history.all(),这显然返回所有模型对象的所有版本的列表。这看起来不错,但我怎样才能过滤出最近的变化并得到最后一次变更的日期?

如果MyModel.history是HistoricalRecords对象访问,如: MyModel.history.last()

什么:

from datetime import datetime 

poll.history.as_of(datetime(2010, 10, 25, 18, 4, 0)) 
<Poll: Poll object as of 2010-10-25 18:03:29.855689> 

poll.history.as_of(datetime(2010, 10, 25, 18, 5, 0)) 
<Poll: Poll object as of 2010-10-25 18:04:13.814128>