How to find records that do not have an empty StringListProperty?

I have the following google appengine app model.

class TestModel(db.Model): names = db.StringListProperty(required=False) 

So, I want to get entries that do not have an empty name property. I tried like this.

 TestModel.all().filter('names !=', []) 

But this throws an exception: BadValueError: filtering by lists is not supported

How can I filter it? or should I check one by one as below?

 for entry in TestModel.all(): if len(entry.names) > 0: result.append(entry) 
+7
source share
1 answer

Try the following:

TestModel.all().filter('names >=', None)

This will give you every entity with at least one value set for the names, i.e. each value in the index.

+6
source

All Articles