mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
fix bug when writing to a dotted field source when the last component doesnt yet exist on the related object
This commit is contained in:
parent
d5d97624f7
commit
cc5096e6e6
|
@ -69,7 +69,7 @@ def set_component(obj, attr_name, value):
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
obj[attr_name] = value
|
obj[attr_name] = value
|
||||||
else:
|
else:
|
||||||
attr = getattr(obj, attr_name)
|
attr = getattr(obj, attr_name, None)
|
||||||
if six.callable(attr):
|
if six.callable(attr):
|
||||||
raise TypeError("%r.%s is a method; can't set it" % (obj, attr_name))
|
raise TypeError("%r.%s is a method; can't set it" % (obj, attr_name))
|
||||||
setattr(obj, attr_name, value)
|
setattr(obj, attr_name, value)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user