make sure the I18nField defaultvalue is not passed by reference
This commit is contained in:
parent
6cfd8eb0e3
commit
af93cd2aa2
3 changed files with 3 additions and 9 deletions
|
@ -174,6 +174,9 @@ class I18nField(JSONField):
|
|||
kwargs.pop('null', None)
|
||||
super().__init__(verbose_name=verbose_name, default=(dict(default) if default else {}), null=False, **kwargs)
|
||||
|
||||
def get_default(self):
|
||||
return self.default.copy()
|
||||
|
||||
def deconstruct(self):
|
||||
name, path, args, kwargs = super().deconstruct()
|
||||
if self.default == {}:
|
||||
|
|
|
@ -52,11 +52,6 @@ class TitledMixin(SerializableMixin, models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if 'titles' not in self.get_deferred_fields():
|
||||
self.titles = self.titles.copy()
|
||||
|
||||
def serialize(self, **kwargs):
|
||||
result = super().serialize(**kwargs)
|
||||
return result
|
||||
|
|
|
@ -81,10 +81,6 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.titles = self.titles.copy()
|
||||
|
||||
def serialize(self, detailed=True, describe_only=False, **kwargs):
|
||||
result = super().serialize(detailed=detailed, **kwargs)
|
||||
if not detailed:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue