Use pk in ReferenceField fixes MongoEngine/mongoengine#85

This commit is contained in:
Ross Lawley 2012-08-24 09:30:08 +01:00
parent a0e3f382cd
commit 0bf2ad5b67

View File

@ -774,7 +774,7 @@ class ReferenceField(BaseField):
if isinstance(document, Document): if isinstance(document, Document):
# We need the id from the saved object to create the DBRef # We need the id from the saved object to create the DBRef
id_ = document.id id_ = document.pk
if id_ is None: if id_ is None:
self.error('You can only reference documents once they have' self.error('You can only reference documents once they have'
' been saved to the database') ' been saved to the database')