Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You can model relationships between entities by storing entity keys as property values. The Python data modeling interface includes several powerful features for managing relationships.
The db.ReferenceProperty declaration describes a
relationship between one model class and another. It stores the key of an
entity as the property value. The first argument to the
db.ReferenceProperty constructor is the model class of the
kind of entity referenced by the property. If someone creates a
relationship to an entity that is not of the appropriate kind, the
assignment raises a db.BadValueError.
You can assign a data object directly to the property. The property
declaration stores the key of the object as the property’s value to create
the relationship. You can also assign a db.Key directly: