相同的代码,在生产中在开发中不起作用是的。
楷模:
class Comput(ndb.Model):
@staticmethod
def membership(user):
q = ndb.gql("SELECT * FROM Members WHERE member = :1", user)
result = q.fetch()
return [m.comput.get() for m in result]
#return [m.comput.get() for m in q] #same issue (dev yes, prod no)
class Members(ndb.Model):
comput = ndb.KeyProperty(kind=Comput)
member = ndb.UserProperty()
处理程序:
comput_list = Comput.membership(users.get_current_user())
模板:
{% for comput in comput_list %}
<tr onclick="location.href='/comput?id={$ comput.key.id() $}'">
追溯(仅在生产中):
UndefinedError: 'None' has no attribute 'key'
即使comput_list
有实体也会出现。
更新:没有为成员自动生成索引,我尝试手动添加但没有任何变化