mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 11:42:54 +03:00
Added a proper deconstruct method to LocalizedValue
This commit is contained in:
parent
7e410e857b
commit
69718c376f
@ -50,6 +50,17 @@ class LocalizedValue:
|
|||||||
setattr(self, language, value)
|
setattr(self, language, value)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def deconstruct(self) -> dict:
|
||||||
|
"""Deconstructs this value into a primitive type.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A dictionary with all the localized values
|
||||||
|
contained in this instance.
|
||||||
|
"""
|
||||||
|
|
||||||
|
path = 'localized_fields.fields.LocalizedValue'
|
||||||
|
return path, [self.__dict__], {}
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Gets the value in the current language, or falls
|
"""Gets the value in the current language, or falls
|
||||||
back to the primary language if there's no value
|
back to the primary language if there's no value
|
||||||
|
@ -36,7 +36,6 @@ class LocalizedFieldWidget(MultiWidget):
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
for lang_code, _ in settings.LANGUAGES:
|
for lang_code, _ in settings.LANGUAGES:
|
||||||
result.append(value.get(lang_code))
|
|
||||||
if value:
|
if value:
|
||||||
result.append(value.get(lang_code))
|
result.append(value.get(lang_code))
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user