标签: python django mongodb pymongo mongoengine
答案 0 :(得分:12)
pymongo的例子:
import pymongo mongo = pymongo.Connection('localhost') collection = mongo['database']['hosts'] collection.ensure_index('host_name', unique=True)
答案 1 :(得分:8)