Mixins — Python Kaos Utils documentation

# Mixins

class py_kaos_utils.mixins.TrackChangesMixin(*args, **kwargs)

  Bases: `object`

  Mixin class that tracks changes made to fields specified in Config.fields_to_track.

  Example:

        >>> class MyModel(TrackChangesMixin, Model):
        >>>    name = CharField()
        >>>    age = IntegerField()
        >>>    class Config:
        >>>        fields_to_track = ['name']
        >>>
        >>> model = MyModel(name="John", age=30)
        >>> model.name = "Mark"
        >>> model.has_field_changed("name") # True
        >>> model.has_field_changed("age") # False

  has_field_changed(field_name)

    Check if the field has changed from its original value

    Parameters

      field_name (str) – name of the field to check

    Returns

      bool indicating whether the field has changed or not