本文整理汇总了Python中models.News.query方法的典型用法代码示例。如果您正苦于以下问题:Python News.query方法的具体用法?Python News.query怎么用?Python News.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.News
的用法示例。
在下文中一共展示了News.query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import query [as 别名]
def get(self):
news_query = News.query().order(-News.date)
feeds = news_query.fetch(15)
template = JINJA_ENVIRONMENT.get_template('templates/home.html')
self.response.write(template.render({'feeds':feeds}))
示例2: list
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import query [as 别名]
def list(page):
q = News.query(News.hot == True).order(-News.post_time)
news, cursor, more =q.fetch_page(PAGESIZE,offset=PAGESIZE*(page-1))
return render_template('list.html', news=news, page=more and page+1 or 0, host=HOST)
示例3: new_list
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import query [as 别名]
def new_list(page):
search_form = SearchForm()
q = News.query().order(-News.post_time)
news, cursor, more =q.fetch_page(PAGESIZE,offset=PAGESIZE*(page-1))
return render_template('new.html',search_form=search_form,news=news, page=more and page+1 or 0, host=HOST,counter=counter.load_and_get_count("view"),acc=ACC)
示例4: admin_index
# 需要导入模块: from models import News [as 别名]
# 或者: from models.News import query [as 别名]
def admin_index(page):
news, cursor, more = News.query().fetch_page(250,offset=250*(page-1))
for new in news:
search.Index(name=_INDEX_NAME).add(create_doc(new.key.id(),new.title,new.url,new.post_time))
logging.info("indexing: "+str(new.key.id()))
return redirect(url_for('home'))