I have a model that is under version control using Django-Reversion. Within a Terminal window I can access all of the previous versions of a model instance using:
foo = FooModel.objects.get()
versions = Version.objects.get_for_object(foo)
When I check versions
it's a set of all the previous versions. However when I call this same function in a view and try to add it to context all I get a in a single VersionQuerySet
that I can't figure out how to iterate through and pull data out of.
Any suggestions?
Try calling list
on the versions
object. This should force the QuerySet to evaluate its items:
versions = Version.objects.get_for_object(foo)
new_versions = list(versions)