Question

I'm using django-reversion for providing history for models I discovered that reversion creates two tables, the table 'reversion_revision' and the 'reversion_version' And in the reversion_revision, are stored the user id who makes last changes. But i cant get that information. I use the function 'reversion.get_for_object(Model)' to get all versions of certain model but the function only return's me the information who is stored in table 'reversion_version' and i need to get the user id of the table reversion_revision Someone now how do i do to get User id?

Était-ce utile?

La solution

revision is a foreign key on Version. And, reversion.get_for_object(Model) simply returns a queryset of Versions. So, for any item in that query set, you can simply access the user as so:

version.revision.user

UPDATE: Just to be more explicit:

versions = reversion.get_for_object(MyModel)

for version in versions:
    print '%s made this revision' % version.revision.user.username
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top