2

On my app I am using django-reversion and django-reversion-compare apps extensions to controll object version.

When I update object outside admin I would like set_comment() with just updated fields. How can I access to list of updated fields and set they as comment of that reversion?

I understand when I compare object version I see which fields was changed, but I want have preview in table history of changes.

I was trying do this by django-dirtyfields, but it was return all fields.

Add objects:

with reversion.create_revision():
    # create or update if exists
    p = Product(reference='010101', name='new name')
    p.save()

Model:

class Product(models.Model):
    reference = models.CharField(max_length=8, unique=True, primary_key=True)
    name = models.CharField(max_length=60, null=True)
user3041764
  • 817
  • 10
  • 35
  • 1
    I ended up using this mixin, it works pretty well even with Django 1.11 – http://stackoverflow.com/a/13842223/3776299 – helb Feb 24 '17 at 13:47
  • This is helpful, but I do not know how to use in my case. I am updating exist object and define new arguments arguments so `self.__initial` and `self._dict` are equal. – user3041764 Feb 24 '17 at 14:43

0 Answers0