Suggested fix for #1047: CachedReferenceField creates DBRef on to_python, but can't save them on to_mongo.

Dereferencing DBRef to document type before returning it from to_python.
This commit is contained in:
amitlicht 2015-06-28 17:53:20 +03:00
parent 1e930fe950
commit 9ce605221a

View File

@ -1034,6 +1034,7 @@ class CachedReferenceField(BaseField):
collection = self.document_type._get_collection_name() collection = self.document_type._get_collection_name()
value = DBRef( value = DBRef(
collection, self.document_type.id.to_python(value['_id'])) collection, self.document_type.id.to_python(value['_id']))
return self.document_type._from_son(self.document_type._get_db().dereference(value))
return value return value