Skip to content

Commit

Permalink
Merge pull request encode#3263 from jgadelange/master
Browse files Browse the repository at this point in the history
Resolved issue with rendering of nested serializers form when value is None
  • Loading branch information
tomchristie committed Aug 13, 2015
2 parents ff5fdee + f5a9904 commit 0e6c467
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rest_framework/utils/serializer_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class NestedBoundField(BoundField):
`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):
for field in self.fields.values():
yield self[field.field_name]
Expand All @@ -101,9 +106,6 @@ def __getitem__(self, key):
return BoundField(field, value, error, prefix=self.name + '.')

def as_form_field(self):
if self.value is None:
return ''

values = {}
for key, value in self.value.items():
if isinstance(value, (list, dict)):
Expand Down

0 comments on commit 0e6c467

Please sign in to comment.