我有一些对象称为展览
对象,它们引用存储在Google App Engine数据存储中的画廊
对象。
当我开始迭代这些值(最终在Django模板中)时,如何对每个画廊
对象上的展览
集合进行排序?
即,以下内容不起作用:
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
在模板中渲染时,相册是按正确顺序排列的,但展品却没有。