django Paginator with Pymongo


在Django 的  Paginator   doc 要一個 A list, tuple, QuerySet, or other sliceable object with a count() or __len__() method. 

但pymongo find 是返回一個Cursor Type  , 所以用 list 配合就最簡單



result = connection.find({'content': 'xxx')})
paginator = Paginator(list(result), 25)

留言