0

I am trying to get the reversion id on the history page.

On my history page, there are links like:

6 May 2015, 3:11 p.m.   root    Initial version.
6 May 2015, 3:36 p.m.   root    Changed description.

The links are respectively:

http://127.0.0.1:8000/admin/app/model/103051/history/4672/
http://127.0.0.1:8000/admin/app/model/103051/history/4674/

How can I access the revision id (4674 or 4672)? The closest I can get is:

>>import reversion
>>model_history = reversion.get_for_object(model_instance)
[<Version: Model103051>, <Version: Model103051>]
>>model_history[0].id
4673L
>>model_history[1].id
4671L

As you can see, the numbers are off by one. I know these are the correct versions, because when I do a model_history[0].revision.comment and model_history[0].revision.date_created match up with the history page.

Is it safe for me to simply take the id and add 1 to get the revision used by django-reversion?

A G
  • 997
  • 2
  • 18
  • 36

1 Answers1

0

I think it has to do with the duplication while saving. and garbage collection afterwards. So some versions in between are deleted later in case duplicate, read the discussion in this issue: https://github.com/etianen/django-reversion/issues/378

michel.iamit
  • 5,788
  • 9
  • 55
  • 74