mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Resolve issue with nested serializers in HTML forms. Closes #3153.
This commit is contained in:
parent
cde7154c59
commit
a8acdbc388
|
@ -72,7 +72,8 @@ class BoundField(object):
|
||||||
))
|
))
|
||||||
|
|
||||||
def as_form_field(self):
|
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):
|
class NestedBoundField(BoundField):
|
||||||
|
@ -93,6 +94,15 @@ class NestedBoundField(BoundField):
|
||||||
return NestedBoundField(field, value, error, prefix=self.name + '.')
|
return NestedBoundField(field, value, error, prefix=self.name + '.')
|
||||||
return BoundField(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):
|
class BindingDict(collections.MutableMapping):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user