0

任何人都知道为什么我对 h1 的数据库查询会弹出?- 这是我得到的错误:谢谢任何人的帮助 - 我一直在看这个,但无法弄清楚....!!!

文件“/Users/minasong/Dropbox/TS Code/main.py”,第 720 行,在 get logging.info("here is the typeable instance %s", type_info.headingtype_name) AttributeError: 'Query' object has no attribute “标题类型名称”

类 AdminHeading_Edit_Type(Handler): def get(self,type_name):

    category_level = "ONE"

    type_info = HeadingType_Table.all().filter("__key__ =", type_name)
    h1 = Level_1_Headings.all().filter("heading_type =", type_info)


    logging.info("here is the type able instance %s ", type_info.headingtype_name)

    self.render('new_entries/ADMIN_Heading_1Edit_2List.html', ones=h1, heading_type=type_name, category_level=category_level, type_into=type_info)      

这是我的数据存储实体定义: class HeadingType_Table(db.Model): headingtype_name = db.StringProperty(required=True, indexed=True) type_description = db.TextProperty()

4

1 回答 1

1

从您的样本中很难分辨,但我怀疑您的问题是这样的;

type_info = HeadingType_Table.all().filter("__key__ =", type_name)

...将 type_info 设置为Query包含所有匹配 "headingtypes"的对象。

logging.info("...", type_info.headingtype_name)

...尝试headingtype_nameQuery对象记录属性。我怀疑你的意思是在一个Model物体上这样做。

要么使用get()而不是all()获取单个Model对象,要么迭代结果以记录从单独返回headingtype_name的每个Model对象Query

于 2013-03-07T20:13:42.877 回答