perf: account history

This commit is contained in:
feng
2026-06-23 19:57:56 +08:00
parent cf4154af7b
commit 53f6d898d6

View File

@@ -23,6 +23,7 @@ class AccountHistoricalRecords(HistoricalRecords):
super().__init__(*args, **kwargs)
def post_save(self, instance, created, using=None, **kwargs):
self.updated_version = None
if not self.included_fields:
return super().post_save(instance, created, using=using, **kwargs)
@@ -51,7 +52,10 @@ class AccountHistoricalRecords(HistoricalRecords):
super().create_historical_record(instance, history_type, using=using)
# Ignore deletion history_type: -
if self.updated_version is not None and history_type != '-':
instance.save(update_fields=['version'])
type(instance)._base_manager.db_manager(using=using).filter(
pk=instance.pk
).update(version=self.updated_version)
self.updated_version = None
def create_history_model(self, model, inherited):
if self.included_fields and not self.excluded_fields: