diff --git a/mongoengine/base.py b/mongoengine/base.py index d4412e2a..ec70e5ad 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -202,9 +202,7 @@ class BaseDocument(object): return all_subclasses def __iter__(self): - # Use _data rather than _fields as iterator only looks at names so - # values don't need to be converted to Python types - return iter(self._data) + return iter(self._fields) def __getitem__(self, name): """Dictionary-style field access, return a field's value if present. diff --git a/mongoengine/queryset.py b/mongoengine/queryset.py index 7b3f7c6b..95f02891 100644 --- a/mongoengine/queryset.py +++ b/mongoengine/queryset.py @@ -132,7 +132,7 @@ class QuerySet(object): """Retrieve the object matching the id provided. """ if not isinstance(object_id, pymongo.objectid.ObjectId): - object_id = pymongo.objectid.ObjectId(object_id) + object_id = pymongo.objectid.ObjectId(str(object_id)) result = self._collection.find_one(object_id) if result is not None: