fix(core): When collecting AuditHistory cater for models being created

ref: #772 #767
This commit is contained in:
2025-05-25 10:28:27 +09:30
parent 5a80e48b21
commit 197cf4eb73

View File

@ -138,10 +138,6 @@ class CenturionModel(
dict: Model fields
"""
if self.id is None:
return {}
data = self.__dict__.copy()
clean_data: dict = {}
@ -239,12 +235,14 @@ class CenturionModel(
self._after = self.get_audit_values()
self._before = {}
if self.id:
self._before = type(self).objects.get( id = self.id ).get_audit_values()
else:
self._before = {}
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)