This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.db.models.signals import pre_save, post_init | |
def track_model_changes(sender, instance, **kwargs): | |
"""Save former data to compare with new data and track changed values""" | |
instance.__former = dict((field.name, field.value_from_object(instance)) for field in Report._meta.fields) | |