本文整理汇总了Python中models.Album.query方法的典型用法代码示例。如果您正苦于以下问题:Python Album.query方法的具体用法?Python Album.query怎么用?Python Album.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Album
的用法示例。
在下文中一共展示了Album.query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import query [as 别名]
def get(self):
query = Album.query().order(-Album.date_created)
albums = get_covered_albums(query, 3)
template_values = {
'albums': albums,
}
self.render_template('index.html', template_values)
示例2: get
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import query [as 别名]
def get(self):
if len(self.request.GET) and self.request.GET['cancel']:
urlstring = self.request.GET['cancel']
album_key = ndb.Key(urlsafe=urlstring)
album_key.delete()
# Order by recently added
album = Album.query(Album.album_type == 'oddmanout').order(-Album.date)
template_values = {
'album_store': album
}
template = JINJA_ENVIRONMENT.get_template('oddmanout.html')
self.response.write(template.render(template_values))
示例3: get
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import query [as 别名]
def get(self):
if users.is_current_user_admin():
photos = Image.query().fetch()
albums = Album.query().fetch()
for photo in photos:
photo_key = ndb.Key(urlsafe=photo.ukey())
photo_key.delete()
for album in albums:
album_key = ndb.Key(urlsafe=album.ukey())
album_key.delete()
self.redirect('/')
示例4: albums_list
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import query [as 别名]
def albums_list(self, request):
current_user = endpoints.get_current_user()
album_type = request.type
email = (current_user.email() if current_user is not None
else 'Anonymous')
albums = Album.query(Album.album_type == album_type).order(-Album.date)
items = []
for album in albums:
a = AlbumMessage(album_id=album.album_id,
title=album.title,
category=album.category,
album_type=album.album_type,
date=str(album.date.date()))
questions = Question.query(ancestor=album.key).order(-Question.date).fetch()
for q in questions:
q_msg = QuestionMessage(question_id=q.question_id, title=q.title, fact=q.fact)
q_images = q.images
for image in q_images:
q_msg.images.append(ImageMessage(title=image.title, correct=image.correct, image_url=image.image))
a.questions.append(q_msg)
items.append(a)
return AlbumCollection(albums=items)