From ed72603d35f9bcbcd2a0bd268791c8e3907ce3e9 Mon Sep 17 00:00:00 2001 From: nerlin Date: Wed, 19 Apr 2017 03:18:52 +0300 Subject: [PATCH] Fixed render error of required nested serializer. Fixes an error that occurs on rendering response with error that says that required nested serializer field must be specified in data. --- rest_framework/utils/serializer_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index 4734332af..e7c53ae00 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -101,7 +101,7 @@ class NestedBoundField(BoundField): def __getitem__(self, key): field = self.fields[key] value = self.value.get(key) if self.value else None - error = self.errors.get(key) if self.errors else None + error = self.errors.get(key) if isinstance(self.errors, dict) else None if hasattr(field, 'fields'): return NestedBoundField(field, value, error, prefix=self.name + '.') return BoundField(field, value, error, prefix=self.name + '.')