mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 03:32:55 +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)
|
||||
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:
|
||||
"""Gets the value in the current language, or falls
|
||||
back to the primary language if there's no value
|
||||
|
@ -36,7 +36,6 @@ class LocalizedFieldWidget(MultiWidget):
|
||||
result = []
|
||||
|
||||
for lang_code, _ in settings.LANGUAGES:
|
||||
result.append(value.get(lang_code))
|
||||
if value:
|
||||
result.append(value.get(lang_code))
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user