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:
Russell Keith-Magee 2006-02-28 11:41:44 +00:00
parent f64c581497
commit a83c077545
1 changed files with 2 additions and 2 deletions

View File

@ -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)