Search code examples
django-simple-history

How to get the last changed object in django-simple-history?


Using django-simple-history, how can I get the last changed object from my model?

I tried MyModel.history.most_recent(), which needs a model instance, so that returns probably the most recent version of a selected instance.

I can query Abonnent.history.all(), which obviously returns a list of all versions of all model objects. This looks good, but how can I filter out the most recent and get the date of the last change?


Solution

  • If MyModel.history is a HistoricalRecords objects you access like: MyModel.history.last()