Search code examples
google-app-enginetagsgoogle-cloud-datastorelistproperty

App engine StringListProperty


I have a model which looks like this:

class test (db.Model) :
 tagList = StringListProperty()
 siteName = StringProperty()

I am storing tags in "tagList" and would like to run a query where I can get all test entities containing a particular tag in their tagList.

Is this possible?


Solution

  • Just use the equality operator.

    q = test.all()
    q.filter("tagList =", "some_tag")
    q.fetch()
    

    For list properties, App Engine treats 'equals' as 'contains'.

    See http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty for details.