我有Exhibit
引用Gallery
对象的对象,这两个对象都存储在 Google App Engine Datastore 中。
当我开始迭代值时(最终在 Django 模板中),如何Exhibit
对每个对象的集合进行排序?Gallery
即这不起作用
class Gallery(db.Model):
title = db.StringProperty()
position = db.IntegerProperty()
class Exhibit(db.Model):
gallery = db.ReferenceProperty(Gallery, collection_name='exhibits')
title = db.StringProperty()
position = db.IntegerProperty()
galleries = db.GqlQuery('SELECT * FROM Gallery ORDER BY position')
for gallery in galleries:
gallery.exhibits.order('position')
# ... send galleries off the the Django template
在模板中呈现时,画廊的顺序正确,但展品的顺序不正确。