views:

50

answers:

1

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?

+2  A: 

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.

hwiechers