gpt4 book ai didi

python - 如何获取尚未绑定(bind)的手动分配的父 ID?

转载 作者:太空宇宙 更新时间:2023-11-03 11:09:40 35 4
gpt4 key购买 nike

我有两个实体

子实体:

class Currency(db.Model):    
country = db.ReferenceProperty(Country)
#...

父实体:

class Country(db.Model):
name = db.StringProperty()
#...

我使用 Currency.cvs 文件中的 appcfg.py upload_data 手动将 country 分配给 currency

当我在控制台输入 currency.country.key 时,我收到此错误消息:

ReferencePropertyResolveError:ReferenceProperty 解析失败:[u'Country', 60L]

如何获取尚未绑定(bind)的国家/地区的ID?

此外,这是它在数据存储面板货币实体中的样子

Entity Kind     Currency
Entity Key ahBkZXZ-ZmluZHlvdXJyb29tchALEghDdXJyZW5jeRiw_wEM
country(Key) ahBkZXZ-ZmluZHlvdXJyb29tcg0LEgdDb3VudHJ5GDwM
Country: id=60

最佳答案

我推测“未绑定(bind)”,你的意思是相关记录还没有加载。您可以使用 Currency.country.get_value_for_datastore(currency_instance) 获取 ReferenceProperty 的键。

关于python - 如何获取尚未绑定(bind)的手动分配的父 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8388409/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com