本文整理匯總了Python中models.News.all方法的典型用法代碼示例。如果您正苦於以下問題:Python News.all方法的具體用法?Python News.all怎麽用?Python News.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.News
的用法示例。
在下文中一共展示了News.all方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from models import News [as 別名]
# 或者: from models.News import all [as 別名]
def get(self, **kwargs):
context = {
'all_news': News.all().order('-date'),
}
context = request_context(context)
return render_response('news.html', **context)
示例2: request_context
# 需要導入模塊: from models import News [as 別名]
# 或者: from models.News import all [as 別名]
def request_context(context):
def js_string(value):
return '\'' + value + '\''
now = datetime.datetime.now(pytz.timezone('America/Argentina/Buenos_Aires'))
# TODO: convert this to a JSON file
js_settings = {
'MEDIA_URL': js_string(settings.MEDIA_URL),
'INITIAL_LOCATION': settings.INITIAL_LOCATION,
'WEEKDAY': js_string(utils.get_weekday_display()),
'CLOCK': simplejson.dumps({
'year': now.year, 'month': now.month, 'day': now.day,
'hour': now.hour, 'minute': now.minute, 'second': now.second
})
}
context.update({
'MEDIA_URL': settings.MEDIA_URL,
'JS_SETTINGS': js_settings,
'news': News.all().order('-date')[:5],
})
return context
示例3: get
# 需要導入模塊: from models import News [as 別名]
# 或者: from models.News import all [as 別名]
def get(self):
news = News.all().order("title").fetch(MAX_FETCH_LIMIT)
news_list = []
for item in news:
news_list.append(item.to_json_dict("title", "is_starred", "is_active", "is_deleted", "when_created"))
self.response.out.write(json.dumps(news_list))