Internals

You might be interested in the way things work on the inside of Auditlog. This section covers the internal APIs of Auditlog which is very useful when you are looking for more advanced ways to use the application or if you like to contribute to the project.

The documentation below is automatically generated from the source code.

Models and fields

Middleware

Signal receivers

Calculating changes

auditlog.diff.get_fields_in_model(instance)[source]

Returns the list of fields in the given model instance. Checks whether to use the official _meta API or use the raw data. This method excludes many to many fields.

Parameters:instance (Model) – The model instance to get the fields for
Returns:The list of fields for the given model (instance)
Return type:list
auditlog.diff.model_instance_diff(old, new)[source]

Calculates the differences between two model instances. One of the instances may be None (i.e., a newly created model or deleted model). This will cause all fields with a value to have changed (from None).

Parameters:
  • old (Model) – The old state of the model instance.
  • new (Model) – The new state of the model instance.
Returns:

A dictionary with the names of the changed fields as keys and a two tuple of the old and new field values as value.

Return type:

dict

auditlog.diff.track_field(field)[source]

Returns whether the given field should be tracked by Auditlog.

Untracked fields are many-to-many relations and relations to the Auditlog LogEntry model.

Parameters:field (Field) – The field to check.
Returns:Whether the given field should be tracked.
Return type:bool

Registry