fixed serialization of lazy attributes that evaluate to None
Without this `None` is returned as the string 'None'. Needed by at least the I18nField
This commit is contained in:
parent
61713caf89
commit
15f2eab217
1 changed files with 6 additions and 0 deletions
|
@ -32,6 +32,12 @@ def make_serializable(values: Any):
|
||||||
return type(values)(val.pk for val in values)
|
return type(values)(val.pk for val in values)
|
||||||
return type(values)(make_serializable(val) for val in values)
|
return type(values)(make_serializable(val) for val in values)
|
||||||
if isinstance(values, Promise):
|
if isinstance(values, Promise):
|
||||||
|
# This is needed for lazy attributes that evaluate to `None` to be serialized properly.
|
||||||
|
# Without this `None` is returned as the string 'None'.
|
||||||
|
# It can't be `is None` as the left side is a Proxy and not actually `None`.
|
||||||
|
# Needed by at least the I18nField
|
||||||
|
if values == None:
|
||||||
|
return None
|
||||||
return str(values)
|
return str(values)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue