【问题标题】:How to find entries which has not empty StringListProperty?如何查找不为空 StringListProperty 的条目?
【发布时间】:2011-08-15 21:32:25
【问题描述】:

我在 Google appengine 应用中有以下模型。

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

所以,我想获取名称属性中不为空的条目。我试过这样。

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

但它引发了异常:BadValueError: Filtering on lists is not supported

如何过滤?还是我应该像下面这样一一检查?

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

【问题讨论】:

    标签: google-app-engine gql


    【解决方案1】:

    试试这个:

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

    这将为您提供至少为名称设置一个值的每个实体,即索引中的每个值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-14
      • 2017-12-18
      • 2012-10-12
      • 1970-01-01
      • 2020-05-15
      相关资源
      最近更新 更多