Skip to content

Instantly share code, notes, and snippets.

View jsanchezpando's full-sized avatar

Outdated (https://github.com/j-san) jsanchezpando

View GitHub Profile
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)