3

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?

Daniel Dias
  • 55
  • 1
  • 10

1 Answers1

6

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
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • ok, I was experimenting with version "version.reversion.get_for_object(model)" but it gives me an error, can not import the version – Daniel Dias Nov 07 '11 at 15:40