From cc5096e6e695e770853fd3c929ed636d857839c1 Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Thu, 29 Aug 2013 17:29:22 +1200 Subject: [PATCH] fix bug when writing to a dotted field source when the last component doesnt yet exist on the related object --- rest_framework/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 21daa91b4..f1be9e047 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -69,7 +69,7 @@ def set_component(obj, attr_name, value): if isinstance(obj, dict): obj[attr_name] = value else: - attr = getattr(obj, attr_name) + attr = getattr(obj, attr_name, None) if six.callable(attr): raise TypeError("%r.%s is a method; can't set it" % (obj, attr_name)) setattr(obj, attr_name, value)