hy I need to add a property to a model that can reference 4 different models:
class WorldObject(db.Model):
# type can only accept: text, image, profile, position
# this should be like a set property in relational database and not a string
type = db.StringProperty(required = True)
# ???: this can be a reference to Profile, Image, Position or Text model
# how to do it?
reference = db.ReferenceProperty(reference_class = ???, required = True)
thanks
@Nick Johnson:
Here is how I've done with your help:
class WorldObject(db.Model):
# x, y: position in the world
x = db.IntegerProperty(required = True)
y = db.IntegerProperty(required = True)
# world: reference to the world containing it
world = db.ReferenceProperty(reference_class = World)
# profile: is the owner of the object and is the only one who can make changes to it's world object property
owner = db.ReferenceProperty(reference_class = Profile, required = False)
# history
updated = db.DateTimeProperty(auto_now_add = True)
created = db.DateTimeProperty(required = True)
then:
class ImageWO(WorldObject):
image = db.ReferenceProperty(reference_class = Image, required = False)
then:
class PositionWO(WorldObject):
position = db.ReferenceProperty(reference_class = Position, required = False)
and the other classes are the same.. Now if I want to get all the world objects in an area how do I do? I have to do 1 request for every class that extends world_object?