mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Resolved issue with rendering of nested serializers form when value is None
This commit is contained in:
parent
a3e64fbe0d
commit
f5a9904cc8
|
@ -88,6 +88,11 @@ class NestedBoundField(BoundField):
|
||||||
`BoundField` that is used for serializer fields.
|
`BoundField` that is used for serializer fields.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, field, value, errors, prefix=''):
|
||||||
|
if value is None:
|
||||||
|
value = {}
|
||||||
|
super(NestedBoundField, self).__init__(field, value, errors, prefix)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for field in self.fields.values():
|
for field in self.fields.values():
|
||||||
yield self[field.field_name]
|
yield self[field.field_name]
|
||||||
|
@ -101,9 +106,6 @@ class NestedBoundField(BoundField):
|
||||||
return BoundField(field, value, error, prefix=self.name + '.')
|
return BoundField(field, value, error, prefix=self.name + '.')
|
||||||
|
|
||||||
def as_form_field(self):
|
def as_form_field(self):
|
||||||
if self.value is None:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
values = {}
|
values = {}
|
||||||
for key, value in self.value.items():
|
for key, value in self.value.items():
|
||||||
if isinstance(value, (list, dict)):
|
if isinstance(value, (list, dict)):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user