ReferenceProperty automatically references and dereferences model instances as property values: A model instance can be assigned to a ReferenceProperty directly, and its key will be used. The ReferenceProperty value can be used as if it were a model instance, and the datastore entity will be fetched and the model instance created when it is first used in this way. Untouched reference properties do not query for unneeded data.
例如:
# Any reference properties not loaded yet
customer = Customer.get_by_id(1)
print customer.name
print customer.address
# Assuming customer.order is a ReferenceProperty, now is when it
# would be loaded from the datastore.
print customer.order.created_at
是的,数据库参考属性字段被延迟加载。来自the docs:
例如:
相关问题 更多 >
编程相关推荐