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)
|
kwargs.pop('null', None)
|
||||||
super().__init__(verbose_name=verbose_name, default=(dict(default) if default else {}), null=False, **kwargs)
|
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):
|
def deconstruct(self):
|
||||||
name, path, args, kwargs = super().deconstruct()
|
name, path, args, kwargs = super().deconstruct()
|
||||||
if self.default == {}:
|
if self.default == {}:
|
||||||
|
|
|
@ -52,11 +52,6 @@ class TitledMixin(SerializableMixin, models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
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):
|
def serialize(self, **kwargs):
|
||||||
result = super().serialize(**kwargs)
|
result = super().serialize(**kwargs)
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -81,10 +81,6 @@ class Location(LocationSlug, AccessRestrictionMixin, TitledMixin, models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
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):
|
def serialize(self, detailed=True, describe_only=False, **kwargs):
|
||||||
result = super().serialize(detailed=detailed, **kwargs)
|
result = super().serialize(detailed=detailed, **kwargs)
|
||||||
if not detailed:
|
if not detailed:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue