我正在使用gae-boilerplate(webapp2和jinja2)。我的模型如下所示:如何通過谷歌應用引擎引用實體使用NDB
class Location(ndb.Model):
x = ndb.FloatProperty()
y = ndb.FloatProperty()
class Criterium(polymodel.PolyModel):
name = ndb.StringProperty(required=True)
user = ndb.KeyProperty(kind='User')
priority = ndb.IntegerProperty(required=True)
class Work(Criterium):
location = ndb.StructuredProperty(Location)
class Friend(Criterium):
location = ndb.StructuredProperty(Location)
我有一個來自Criterium模型的所有記錄的表。我想在那裏添加一個刪除鏈接,但我不知道爲了引用特定的實體而使用它來傳遞什麼參數。我的處理程序是這樣的:
def get(self):
criteria = Work.query().order(-Criterium.priority, Criterium.name)
self.view.list_columns = [('name', 'Name'),
('priority', 'Priority'),
('className', 'Type')]
self.view.criteria = criteria
self.view.count = criteria.count()
params={}
self.render_template('list.html', **params)
似乎是一個簡單的問題,卻一直在掙扎了一整天...提前感謝!
單數標準是'標準',而不是'標準'。 – 2013-03-19 16:27:29
謝謝。不知何故,我不喜歡「標準」這個詞。 – 2013-03-19 17:35:19