私は自分の心を失っていると思うのですが、なぜ次の作業をしないのですか?App EngineをListPropertyに追加する
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()
私はこのエラーを取得する:
BadValueError: Property childrenKeys is required
DOCは言う:
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.
だから私はそれを参照してください方法は、私はデフォルト(空のリスト)を取得し、追加しています新しい価値とそれを保存すること。これで
p.childrenKeys = p.childrenKeys.append('newchildkey')
:
p.childrenKeys.append('newchildkey')
append()
戻りNone
、p.childrenKeys
に割り当てることができない、これを元に戻し
class Parent(db.Model):
childrenKeys = db.ListProperty(str,indexed=False,default=[])
p = Parent.get_or_insert('somekey')
p.childrenKeys.append('newchkey')
p.put()
いずれにせよ、 'ListProperty(str)'ではなく 'StringListProperty'が必要です。 (これがうまくいく場合は、最近のSDKで変更されている可能性があります)。 – geoffspear