本文整理汇总了Python中models.Topic.count_search方法的典型用法代码示例。如果您正苦于以下问题:Python Topic.count_search方法的具体用法?Python Topic.count_search怎么用?Python Topic.count_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Topic
的用法示例。
在下文中一共展示了Topic.count_search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import count_search [as 别名]
def search():
query = request.args.get('query', '')
query = query.strip()
if len(query) == 0:
return redirect('/')
offset = int(request.args.get('offset', 0))
limit = int(request.args.get('limit', 10))
# search articles
result = Article.search(query, offset=offset, limit=limit)
articles = result.get('data')
articles = [article.json_data() for article in articles]
context = {
'search': query,
'offset': offset,
'limit': limit,
'js_module': 'search',
'style': 'search',
'articles': articles,
'total_article': result['raw']['total_found'],
'total_topic': Topic.count_search(query)
}
return render_template('site/search.html', **context)
示例2: search
# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import count_search [as 别名]
def search():
query = request.args.get('query')
limit = int(request.args.get('limit', 10))
offset = int(request.args.get('offset', 0))
result = Topic.search(query, offset=offset, limit=limit)
topics = result.get('data')
pagination = dict(
limit=limit,
offset=offset,
total=Topic.count_search(query)
)
return jsonify(dict(
data=[topic.json_data() for topic in topics],
pagination=pagination
))