query = leancloud.Query("Photo")
    photo = query.get('idxxx')
    file = photo.get('file')
    file.get('objectId')  # 结果预期:idxxx
    file.get('custom_field')  # 非预期:None
    file.get('createdAt')  # 非预期:None
  • 通过 pointer 访问外键对象,不能正常使用了
  • 在一个月前,该代码表现都是预期的,现在跑不起来了
  • python sdk: leancloud 2.9.7

你好,在您的例子中,如果 photo 对象的 file 字段是一个文件,由于文件表不支持自定义字段,所以 Python SDK 没有支持通过 get 方法来获取文件的属性。如果您需要获取文件的 metaData,可以通过 file.metadata 来获取。

对于 Pointer 类型的字段,如果需要获取关联对象的各个字段的值,需要在查询上使用 include 方法,例如 query.include('file')

1 人赞了这个帖子.

谢谢!我的问题解决了。
通过 include 进行多级查询!