Resolve issue with nested serializers in HTML forms. Closes #3153.

This commit is contained in:
Tom Christie 2015-07-16 12:04:38 +01:00
parent cde7154c59
commit a8acdbc388

View File

@ -72,7 +72,8 @@ class BoundField(object):
))
def as_form_field(self):
return self.__class__(self._field, force_text(self.value), self.errors, self._prefix)
value = force_text(self.value)
return self.__class__(self._field, value, self.errors, self._prefix)
class NestedBoundField(BoundField):
@ -93,6 +94,15 @@ class NestedBoundField(BoundField):
return NestedBoundField(field, value, error, prefix=self.name + '.')
return BoundField(field, value, error, prefix=self.name + '.')
def as_form_field(self):
values = {}
for key, value in self.value.items():
if isinstance(value, (list, dict)):
values[key] = value
else:
values[key] = force_text(value)
return self.__class__(self._field, values, self.errors, self._prefix)
class BindingDict(collections.MutableMapping):
"""