我正在使用App Engine,SDK 1.6.3和Python 2.7。App Engine - AttributeError:'function'object has no attribute'id'
我创建了一个模型是这样的:
class MyModel(db.Model):
name = db.StringProperty()
website = db.StringProperty()
我可以遍历,看看除了密钥ID的一切。例如,在交互式shell中,我可以运行以下代码:
from models import *
list = MyModel.all()
for p in list:
print(p.name)
并打印每个实体的名称。但是,当我运行此:
from models import *
list = MyModel.all()
for p in list:
print(p.key.id) [or p.key.name or p.key.app]
我得到一个AttributeError:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/admin/__init__.py", line 317, in post
exec(compiled_code, globals())
File "<string>", line 4, in <module>
AttributeError: 'function' object has no attribute 'id'
谁能帮我?
太棒了;谢谢!我简直不敢相信那么简单...... – 2012-03-22 01:36:30