anfema_django_utils.db.mixins.SnapshotFieldValuesModelMixin

class SnapshotFieldValuesModelMixin

Bases: anfema_django_utils.db.mixins.ChangedFieldValuesMixinBase

Mixin to keep track of changed field values based on snapshots.

Field value snapshots are created whenever a model instance is initialized. This happens on model initialization, creation or refresh_from_db calls for example.

To manually create a field value snapshot, call the snapshot_field_values() method.

Only concrete (and non-deferred) field values are captured currently, for foreign keys for example only the <fk_field>_id key is present.

Methods

snapshot_field_values([field_names])

rtype:

None

Attributes

current_field_value_snapshot

property current_field_value_snapshot: Dict[str, Any]
snapshot_field_values(field_names=None)
Return type:

None