def _has_changed(instance):
    """
    Check if some tracked fields have changed
    """
    for field, value in instance._original_fields.items():
        if field != 'pk' and \
           not isinstance(instance._meta.get_field(field), ManyToManyField):
            try:
                if field in getattr(instance, '_tracked_fields', []):
                    if isinstance(instance._meta.get_field(field), ForeignKey):
                        if getattr(instance, '{0}_id'.format(field)) != value:
                            return True
                    else:
                        if getattr(instance, field) != value:
                            return True
            except TypeError:
                # Can't compare old and new value, should be different.
                return True
    return False
def _has_changed ( instance ) : for field , value in instance . _original_fields . items ( ) : if field != 'pk' and not isinstance ( instance . _meta . get_field ( field ) , ManyToManyField ) : try : if field in getattr ( instance , '_tracked_fields' , [ ] ) : if isinstance ( instance . _meta . get_field ( field ) , ForeignKey ) : if getattr ( instance , '{0}_id' . format ( field ) ) != value : return True else : if getattr ( instance , field ) != value : return True except TypeError : return True return False
Check if some tracked fields have changed