本文整理匯總了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)