mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 11:42:54 +03:00
Fix aggregation not expanding into a actual list
This commit is contained in:
parent
2d5fe0be05
commit
e5214b07ae
@ -66,6 +66,22 @@ class LocalizedField(HStoreField):
|
|||||||
else:
|
else:
|
||||||
return cls.attr_class()
|
return cls.attr_class()
|
||||||
|
|
||||||
|
# we can get a list if an aggregation expression was used..
|
||||||
|
# if we the expression was flattened when only one key was selected
|
||||||
|
# then we don't wrap each value in a localized value, otherwise we do
|
||||||
|
if isinstance(value, list):
|
||||||
|
result = []
|
||||||
|
for inner_val in value:
|
||||||
|
if isinstance(inner_val, dict):
|
||||||
|
if inner_value is None:
|
||||||
|
result.append(None)
|
||||||
|
else:
|
||||||
|
result.append(cls.attr_class(inner_val))
|
||||||
|
else:
|
||||||
|
result.append(inner_val)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
return cls.attr_class(value)
|
return cls.attr_class(value)
|
||||||
|
|
||||||
def to_python(self, value: Union[dict, str, None]) -> LocalizedValue:
|
def to_python(self, value: Union[dict, str, None]) -> LocalizedValue:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user