我有一个应用程序,它用所有者的电子邮件存储实体。我的 models.py 看起来像这样:
from google.appengine.ext import db
from google.appengine.api import users
class GenericModel(db.Model):
'''GenericModel is inherited by other model definitions.'''
DateAdded = db.DateTimeProperty(auto_now_add = True)
owner = db.UserProperty()
class CASentry(GenericModel):
description = db.TextProperty()
date = db.DateProperty()
hours = db.FloatProperty()
location = db.StringProperty()
当我从开发服务器上的交互式控制台运行它时:
from google.appengine.ext import db
t = db.GqlQuery('''SELECT * FROM CASentry''').fetch(1)[0]
print t.owner
t = db.GqlQuery('''SELECT * FROM CASentry where owner = 'test@example.com' ''').fetch(1)
print t
我明白了:
test@example.com
[]
我觉得期待这样的事情:
test@example.com
[<models.CASentry object at 0x123456>]
谁能看到我的代码有问题?