File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 11from flask .json import JSONEncoder
22from bson import json_util
33from mongoengine .base import BaseDocument
4- from mongoengine import QuerySet
5-
4+ try :
5+ from mongoengine .base import BaseQuerySet
6+ except ImportError as ie : # support mongoengine < 0.7
7+ from mongoengine .queryset import QuerySet as BaseQuerySet
68
79def _make_encoder (superclass ):
810 class MongoEngineJSONEncoder (superclass ):
911 '''
1012 A JSONEncoder which provides serialization of MongoEngine
11- documents and querysets .
13+ documents and queryset objects .
1214 '''
1315 def default (self , obj ):
1416 if isinstance (obj , BaseDocument ):
1517 return json_util ._json_convert (obj .to_mongo ())
16- elif isinstance (obj , QuerySet ):
18+ elif isinstance (obj , BaseQuerySet ):
1719 return json_util ._json_convert (obj .as_pymongo ())
1820 return superclass .default (self , obj )
1921 return MongoEngineJSONEncoder
You can’t perform that action at this time.
0 commit comments