jazzband / django-simple-history

Store model history and view/revert changes from admin site.
https://django-simple-history.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.21k stars 479 forks source link

Diff between current and historical #599

Open december1981 opened 5 years ago

december1981 commented 5 years ago

Since an ORM "update()" is not the same as an explicit loop and ".save()" over the affected instances (as you note in the docs), we sometimes get differences between between the actual instance and the last created historical instance.

So I was going to make a change and fire off a pull request to add a feature like

pukka_instance.history.diff_against(historical_instance)

(there's currently no way to diff an actual instance with a historical one)

What say thee (before I go ahead with this)?

kseever commented 4 years ago

Hey! We currently have diff_against() here. Was this not sufficient for your needs?

december1981 commented 4 years ago

The problem with this is that it works only between two historical instances. I wanted something that would allow a difference between the current, actual, instance of an object and one of the historical instances (actually, the latest historical instance.)

As mentioned, the actual instance can be different from the latest historical instance, esp. if someone or some process runs an update on an instance instead of saving via save().