Fixed the save method of the LocalizedModel data model to find the l10n records only for existing models, to work with Django 4.1.

This commit is contained in:
依瑪貓 2022-12-04 23:01:02 +08:00
parent 4afd072cc5
commit f57162a93c

View File

@ -126,6 +126,9 @@ class LocalizedModel(models.Model):
current_value = getattr(self, name + "_l10n") current_value = getattr(self, name + "_l10n")
if current_value is None or current_value == "": if current_value is None or current_value == "":
setattr(self, name + "_l10n", new_value) setattr(self, name + "_l10n", new_value)
if self.pk is None:
l10n_rec = None
else:
l10n_rec = self._get_l10n_set()\ l10n_rec = self._get_l10n_set()\
.filter(name=name, language=language)\ .filter(name=name, language=language)\
.first() .first()