File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,19 +86,22 @@ def to_internal_value(self, data):
8686
8787 def to_representation (self , obj ):
8888 """Serialize the field's JSON data, for read operations."""
89- for k , v in obj .items ():
90- if v is None : # NoneType is used to unset a value
91- continue
92-
93- try :
94- if isinstance (v , (dict , list )):
95- self .to_representation (v )
96- elif self .convert_to_str :
97- obj [k ] = str (v )
98- except ValueError :
99- obj [k ] = v
100- # Do nothing, the validator will catch this later
89+ if isinstance (obj , dict ):
90+ for k , v in obj .items ():
91+ if v is None : # NoneType is used to unset a value
92+ continue
10193
94+ try :
95+ if isinstance (v , (dict , list )):
96+ self .to_representation (v )
97+ elif self .convert_to_str :
98+ obj [k ] = str (v )
99+ except ValueError :
100+ obj [k ] = v
101+ # Do nothing, the validator will catch this later
102+ elif isinstance (obj , list ):
103+ for i in range (len (obj )):
104+ obj [i ] = self .to_representation (obj [i ])
102105 return obj
103106
104107
You can’t perform that action at this time.
0 commit comments