doing something with revision object right after it's created

26 views
Skip to first unread message

David Jiang

unread,
Dec 28, 2015, 11:57:30 AM12/28/15
to django-reversion discussion group
Hello,

All my models inherit from an abstract parent model which have a save method that looks like this

def save(self, *args, **kwargs):
    with transaction.atomic(), reversion.create_revision():
        return super(LogItModel, self).save(*args, **kwargs)

I want to write the reversion object to a log as it's created within the with statement. Is there a way to access the reversion object created with reversion.create_revision()?

I tried doing
with transaction.atomic(), reversion.create_revision() as version:
    print(version)

but it is printing None.

Thanks!

David Jiang

unread,
Dec 28, 2015, 12:46:53 PM12/28/15
to django-reversion discussion group
Update:

Found the revision commit signal. This worked well for my purposes.

def on_revision_commit(**kwargs):
    pass
reversion.post_revision_commit.connect(on_revision_commit)
Reply all
Reply to author
Forward
0 new messages