Fix derefcence failed some case.
This commit is contained in:
		| @@ -339,7 +339,7 @@ class ComplexBaseField(BaseField): | ||||
|                     # _types / _cls data so make it a generic reference allows | ||||
|                     # us to dereference | ||||
|                     meta = getattr(v, 'meta', getattr(v, '_meta', {})) | ||||
|                     if meta and not meta['allow_inheritance'] and not self.field: | ||||
|                     if meta and not meta.get('allow_inheritance', True) and not self.field: | ||||
|                         from fields import GenericReferenceField | ||||
|                         value_dict[k] = GenericReferenceField().to_mongo(v) | ||||
|                     else: | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import pymongo | ||||
|  | ||||
| from base import (BaseDict, BaseList, TopLevelDocumentMetaclass, get_document) | ||||
| from fields import ReferenceField | ||||
| from fields import (ReferenceField, ListField, DictField, MapField) | ||||
| from connection import get_db | ||||
| from queryset import QuerySet | ||||
| from document import Document | ||||
| @@ -102,7 +102,7 @@ class DeReference(object): | ||||
|                 for key, doc in references.iteritems(): | ||||
|                     object_map[key] = doc | ||||
|             else:  # Generic reference: use the refs data to convert to document | ||||
|                 if doc_type: | ||||
|                 if doc_type and not isinstance(doc_type, (ListField, DictField, MapField,) ): | ||||
|                     references = doc_type._get_db()[col].find({'_id': {'$in': refs}}) | ||||
|                     for ref in references: | ||||
|                         doc = doc_type._from_son(ref) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user