views:

177

answers:

2

I would like to create a Group model in Google App Engine and then have an attribute where I can create a list of UserReferences. The documentation said:

"A property can have multiple values, represented in the datastore API as a Python list. The list can contain values of any of the value types supported by the datastore."

Would I implement this by creating:

class Group(db.Model): group_list = db.ListProperty(users.User)

Or might I be better served by simply listing the user entity keys?

http://code.google.com/appengine/docs/python/datastore/entitiesandmodels.html

+1  A: 

keys are better placed in ReferenceProperty and their purpose is to create relationships between two kinds. You can simply create the listproperty and as your list grows keep adding listitems to it.

class Group(db.Model): 
  group_list = db.ListProperty()
dhaval
A: 

This depends on your use-case. If you already have a User model, to store additional data about your users, then using a db.ListProperty(Key) for User model keys is probably your best option.

Nick Johnson