Don't raise exception if ListField/DictField are stored as None
This commit is contained in:
parent
628a8dacfa
commit
17a1844b6f
1 changed files with 2 additions and 2 deletions
|
|
@ -527,7 +527,7 @@ class ListField(ComplexBaseField):
|
||||||
|
|
||||||
def to_python(self, val):
|
def to_python(self, val):
|
||||||
to_python = getattr(self.field, 'to_python', None)
|
to_python = getattr(self.field, 'to_python', None)
|
||||||
return [to_python(v) for v in val] if to_python else val
|
return [to_python(v) for v in val] if to_python and val else val or None
|
||||||
|
|
||||||
def to_mongo(self, val):
|
def to_mongo(self, val):
|
||||||
to_mongo = getattr(self.field, 'to_mongo', None)
|
to_mongo = getattr(self.field, 'to_mongo', None)
|
||||||
|
|
@ -615,7 +615,7 @@ class DictField(ComplexBaseField):
|
||||||
|
|
||||||
def to_python(self, val):
|
def to_python(self, val):
|
||||||
to_python = getattr(self.field, 'to_python', None)
|
to_python = getattr(self.field, 'to_python', None)
|
||||||
return {k: to_python(v) for k, v in val.iteritems()} if to_python else val
|
return {k: to_python(v) for k, v in val.iteritems()} if to_python and val else val or None
|
||||||
|
|
||||||
def value_for_instance(self, value, instance, name=None):
|
def value_for_instance(self, value, instance, name=None):
|
||||||
name = name or self.name
|
name = name or self.name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue