mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 11:42:54 +03:00
String constructor for LocalizedValue
This allows you to do: LocalizedValue('thing'), which would result in a LocalizedValue looking like this: {'en': 'thing', 'ar': None}
This commit is contained in:
parent
2c5090f7a9
commit
3adfe509b2
@ -15,6 +15,9 @@ class LocalizedValue:
|
||||
different language.
|
||||
"""
|
||||
|
||||
if isinstance(keys, str):
|
||||
setattr(self, settings.LANGUAGE_CODE, keys)
|
||||
else:
|
||||
for lang_code, _ in settings.LANGUAGES:
|
||||
value = keys.get(lang_code) if keys else None
|
||||
setattr(self, lang_code, value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user