Accessing a missing field now returns None rather than raising an AttributeError

This commit is contained in:
Harry Marr
2009-12-24 17:10:36 +00:00
parent 3d70b65a45
commit f687bad202
5 changed files with 14 additions and 17 deletions

View File

@@ -181,9 +181,8 @@ class ReferenceField(BaseField):
if isinstance(document, (str, unicode, pymongo.objectid.ObjectId)):
id_ = document
else:
try:
id_ = document.id
except:
id_ = document.id
if id_ is None:
raise ValidationError('You can only reference documents once '
'they have been saved to the database')