does ndb have a list property

robert king picture robert king · Aug 10, 2012 · Viewed 7.4k times · Source

Instead of a single StringProperty(), I want to store a list of strings

class BlogPost(ndb.Model):
    s1 = ndb.StringProperty(required=True)
    s2 = ndb.StringProperty(required=True)
    s3 = ndb.StringProperty(required=True)

I would rather go

class BlogPost(ndb.Model):
    my_strings = ndb.StringListProperty() # does this exist?

Answer

robert king picture robert king · Aug 10, 2012

yes, use a repeated property:

Any property with repeated=True becomes a repeated property. The property takes a list of values of the underlying type, rather than a single value. For example, the value of a property defined with IntegerProperty(repeated=True) is a list of integers.

see the docs: Repeated Properties