Search code examples
djangogoogle-app-enginedjango-modelsdjango-nonreldjangoappengine

Equivalent replacement for ListProperty(db.Key) in djangoappengine


I and trying to use djangoappengine, but I am unsure how can I write model to incorporate standard

ListProperty(db.Key) 

I know that djangotoolbox provides this field types but I am unable to figure out the exact syntax.


Solution

  • db.ListProperty(db.Key) stores a list of any entity's keys.

    models:

    class Profile(db.Model):
    data_list=db.ListProperty(db.Key)
    
    class Data(db.Model):
    name=db.StringProperty()
    

    views:

    prof=Profile()
    data=Data.all()
    
    for data in data:
        prof.data_list.append(data)
    
    /// Here data_list stores the keys of Data entity
    
    Data.get(prof.data_list) will get all the Data entities whose key are in the data_list attribute