Reputation: 7180
I think I'm loosing my mind, why doens't the following work?
class Parent(db.Model):
childrenKeys = db.ListProperty(str,indexed=False,default=None)
p = Parent.get_or_insert(key_name='somekey')
p.childrenKeys = p.childrenKeys.append('newchildkey')
p.put()
I get this error:
BadValueError: Property childrenKeys is required
The doc says:
default is the default value for the list property. If None, the default is an empty list. A list property can define a custom validator to disallow the empty list.
So the way I see it, I'm getting the default (an empty list) and appending a new value to it and the saving it.
Upvotes: 5
Views: 2964
Reputation: 74134
You should remove the p.childrenKeys
assignment:
class Parent(db.Model):
childrenKeys = db.ListProperty(str,indexed=False,default=[])
p = Parent.get_or_insert('somekey')
p.childrenKeys.append('newchkey')
p.put()
Upvotes: 8
Reputation: 2111
Replace this:
p.childrenKeys = p.childrenKeys.append('newchildkey')
with this:
p.childrenKeys.append('newchildkey')
append()
returns None
, which can't be assigned to p.childrenKeys
.
Upvotes: 5