magic-removal: Refs #1407 -- Modified descriptor set method to ask forgiveness rather than permission.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2436 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f64c581497
commit
a83c077545
|
@ -106,9 +106,9 @@ class SingleRelatedObjectDescriptor(object):
|
||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
# Set the value of the related field
|
# Set the value of the related field
|
||||||
if value:
|
try:
|
||||||
val = getattr(value, self._field.rel.get_related_field().attname)
|
val = getattr(value, self._field.rel.get_related_field().attname)
|
||||||
else:
|
except AttributeError:
|
||||||
val = None
|
val = None
|
||||||
setattr(instance, self._field.attname, val)
|
setattr(instance, self._field.attname, val)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue