如何找到没有清空StringListProperty的条目? [英] How to find entries which has not empty StringListProperty?
本文介绍了如何找到没有清空StringListProperty的条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class TestModel(db.Model):
我在Google appengine应用程序中使用了以下模型。 names = db.StringListProperty(required = False)
所以,我想获得没有空的条目在名称属性。
$ b
TestModel.all()。filter('names!=',[])
但引发异常: BadValueError:不支持列表过滤
我如何过滤它?或者我应该像下面一样检查一下吗?
用于在TestModel.all()中输入:
if len entry.names)> 0:
result.append(entry)
解决方案
试试这个:
TestModel.all()。filter('names> =',None)
这会为每个实体提供至少一个名称值,即索引中的每个值。
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)
解决方案
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.
这篇关于如何找到没有清空StringListProperty的条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文