具有动态TextProperty的NDB Expando模型? [英] NDB Expando Model with dynamic TextProperty?
本文介绍了具有动态TextProperty的NDB Expando模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试:
MyModel({'text': db.Text('text longer than 500 byets')})
但是得到:
BadValueError: Indexed value fb_education must be at most 500 bytes
我认为这只是旧数据库api对这一问题的影响.
I'm thinking this is just a carry over from this issue with the old db api.
https://groups.google.com/forum/?fromgroups#!topic/google-appengine/wLAwrjtsuks
推荐答案
首先动态创建实体:
kindOfEntity = "MyTable"
class DynamicEntity(ndb.Expando):
@classmethod
def _get_kind(cls):
return kindOfEntity
然后按如下所示动态/动态分配文本属性,如下所示
then after to assign Text Properties run time/dynamically as shown below
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()
然后在为关键属性分配了文本属性之后
then after key properties assign with Text properties
这篇关于具有动态TextProperty的NDB Expando模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文