我试图访问一个由Google应用程序引擎中的db.ReferenceProperty链接的对象。下面是这个模型的代码:如何对Google AppEngine进行反向引用?
class InquiryQuestion(db.Model):
inquiry_ref = db.ReferenceProperty(reference_class=GiftInquiry, required=True, collection_name="inquiry_ref")
,我试图访问它以下列方式:
linkedObject = question.inquiry_ref
然后
linkedKey = linkedObject.key
,但它不工作。任何人都可以帮忙吗?
我试过上面: linkedObject = question.inquiry_ref.get() 而我在我的日志中的以下错误: 的get()到底需要2个参数(1给出) 回溯(最近调用最后一次): 文件 “/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py”,第513行,在__call__中 handler.post(* groups) File“/ base/data/home/apps/chowbird/1.342412733116965934/actions.py“,第126行,后 linkedObject = question.inquiry_ref.get() TypeError:get()只需要2个参数(给出1) – jCuga 2010-06-03 17:49:45
问题的类型是什么。这是一个InquiryQuestion还是一个GiftInquiry?我认为你可能想要使用第二种形式:linkedObject = db.get(question.inquiery_ref)。 – 2010-06-03 17:51:17