Allow raw dicts to be used in update statements

This commit is contained in:
Swen Kooij
2018-03-31 16:53:10 +03:00
parent 8fbe3e8680
commit ccc46e1899
2 changed files with 52 additions and 0 deletions

View File

@@ -131,6 +131,8 @@ class LocalizedField(HStoreField):
specified, we'll treat it as an empty :see:LocalizedValue
instance, on which the validation will fail.
Dictonaries are converted into :see:LocalizedValue instances.
Arguments:
value:
The :see:LocalizedValue instance to serialize
@@ -141,6 +143,9 @@ class LocalizedField(HStoreField):
extracted from the specified value.
"""
if isinstance(value, dict):
value = LocalizedValue(value)
# default to None if this is an unknown type
if not isinstance(value, LocalizedValue) and value:
value = None