fix(core): If model does not save history, dont attempt to cache before

ref: #732
This commit is contained in:
2025-04-26 06:19:35 +09:30
parent c152dd13f1
commit b476bd458e

View File

@ -211,12 +211,14 @@ class SaveHistory(models.Model):
is the data that was saved to the DB.
"""
before = {}
if self.save_model_history:
try:
before = self.__class__.objects.get(pk=self.pk).__dict__.copy()
except Exception:
pass
before = {}
try:
before = self.__class__.objects.get(pk=self.pk).__dict__.copy()
except Exception:
pass
# Process the save
super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)