我正在尝试做:

MyModel({'text': db.Text('text longer than 500 byets')})


但是得到:

BadValueError: Indexed value fb_education must be at most 500 bytes


我认为这只是旧数据库api对这一问题的影响。

https://groups.google.com/forum/?fromgroups#!topic/google-appengine/wLAwrjtsuks

最佳答案

首先动态创建实体:

 kindOfEntity = "MyTable"
class DynamicEntity(ndb.Expando):
     @classmethod
     def _get_kind(cls):
        return kindOfEntity


然后在分配文本属性运行时间/动态之后,如下所示

dbObject = DynamicEntity()
key = "studentName"
value = "Vijay Kumbhani"
textProperties = ndb.TextProperty(key)
dbObject._properties[key] = {}
dbObject._values[key] = {}
dbObject._properties[key] = textProperties
dbObject._values[key] = value
dbObject.put()


然后在为关键属性分配文本属性后

10-06 03:41