Copying from my post @ http://spapas.github.io/2015/01/21/django-model-auditing/#using-django-reversion
[...] each version has a revision
attribute for the corresponding revision and can be used to do the following:
- get the user that made the change through the
revision.user
attribute
- get the date of the change through the
revision.date_created
attribute
- get the values of the object fields as they were in this revision using the
field_dict
attribute
- get a model instance as it was on that revision using the
object_version.object
attribute
- revert to that previous version of that object using the
revert()
method
So try changing your return version.get_object()
line to return version.object_version.object
!
Update to answer OP's comment for related objects: django-reversion supports revisions that group changes to models -- copying from http://django-reversion.readthedocs.org/en/latest/api.html#creating-revisions
A revision represents one or more changes made to your models, grouped together as a single unit. You create a revision by marking up a section of code to represent a revision. Whenever you call save() on a model within the scope of a revision, it will be added to that revision.
So, if you change all your models in a single POST request you can add it in a revision to make all your changed objects members of that revision. After that, when you have a version of the object you can use its reversion to get all the versions of all objects that belong to the same revision: version.revision.version_set.all()
.
If you don't actually save the related objects when you save the main object so the related objects don't belong to the revision, then yes, you need to go down the rabbit hole and get the revisions of the related objects as they were on the date of the main object revision (this is a rather complex query).