How to find entries which has not empty StringListProperty?

自古美人都是妖i 提交于 2019-12-08 18:51:51

问题


I have a following model in the Google appengine app.

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

So, I want to get entries which has not empty in names property. I tried like this.

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

But it raises the exception: BadValueError: Filtering on lists is not supported

How can I filter it? or Should I check one by one like following?

for entry in TestModel.all():
  if len(entry.names) > 0:
     result.append(entry)

回答1:


Try this:

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

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



来源:https://stackoverflow.com/questions/5839125/how-to-find-entries-which-has-not-empty-stringlistproperty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!