本文整理汇总了Python中eulexistdb.query.QuerySet.distinct方法的典型用法代码示例。如果您正苦于以下问题:Python QuerySet.distinct方法的具体用法?Python QuerySet.distinct怎么用?Python QuerySet.distinct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eulexistdb.query.QuerySet
的用法示例。
在下文中一共展示了QuerySet.distinct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_distinct
# 需要导入模块: from eulexistdb.query import QuerySet [as 别名]
# 或者: from eulexistdb.query.QuerySet import distinct [as 别名]
def test_distinct(self):
qs = QuerySet(using=self.db, collection=COLLECTION, xpath='//name')
vals = qs.distinct()
self.assert_('one' in vals)
self.assert_('two' in vals)
self.assert_('three' in vals)
self.assert_('four' in vals)
self.assert_('abc' not in vals)
示例2: index
# 需要导入模块: from eulexistdb.query import QuerySet [as 别名]
# 或者: from eulexistdb.query.QuerySet import distinct [as 别名]
def index(request):
# XML and SPARQL numbers
# Count texts and authors
qs = QuerySet(using=ExistDB(), xpath='/tei:TEI', collection='docker/texts/', model=RocheTEI)
qs = qs.filter(chapter='1')
qs = qs.only('title', 'title_en', 'author')
# TODO: order by title
qs = qs.order_by('title_en')
number_texts = qs.count()
number_authors = qs.distinct().count()
wiki_pages = []
for page in sorted(os.listdir("/docker/dublin-store/sinology/mainSpace")):
wiki_pages.append([page.replace(" ", "%20"), page])
data = {'number_texts': number_texts, 'number_authors': number_authors,
'tei_documents': qs, "wiki_pages": wiki_pages, }
return render(request, 'roche/index.html', data)