mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-10-29 18:18:57 +03:00
Add LocalizedValue.is_empty()
This commit is contained in:
@@ -136,6 +136,15 @@ class LocalizedValue(dict):
|
||||
|
||||
return None
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
"""Gets whether all the languages contain the default value."""
|
||||
|
||||
for lang_code, _ in settings.LANGUAGES:
|
||||
if self.get(lang_code) != self.default_value:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Gets the value in the current language or falls back to the next
|
||||
language if there's no value in the current language."""
|
||||
|
||||
Reference in New Issue
Block a user