Skip to content

History Save


Bases: Model

Attributes

save_model_history: bool = True

When set, history will be saved. By default, ALL models must save history.

fields

Classes

Meta

Attributes

abstract = True

Functions

save_history(before, after)

Save a Models Changes

Parameters:

Name Type Description Default
before dict

model before saving (model.objects.get().dict)

required
after dict

model after saving and refetched from DB (model.objects.get().dict)

required

save(force_insert=False, force_update=False, using=None, update_fields=None)

OverRides save for keeping model history.

Not a Full-Override as this is just to add to existing.

Before to fetch from DB to ensure the changed value is the actual changed value and the after is the data that was saved to the DB.

delete_history(item_pk, item_class)

Delete the objects history

When an object is no longer in the database, delete the objects history and that of the child objects. Only caveat is that if the history has a parent_pk the object history is not to be deleted.

Parameters:

Name Type Description Default
item_pk int

Primary key of the object to be deleted

required
item_class str

Object class of the object to be deleted

required

delete(using=None, keep_parents=False)

OverRides delete for keeping model history and on parent object ONLY!.

Not a Full-Override as this is just to add to existing.

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-06-16
Date Edited: 2024-07-13

Contribution:

Would You like to contribute to our Centurion ERP project? You can assist in the following ways:

 

ToDo: Add the page list of contributors