?
最佳答案
我想有两个选择。
使用expando。You can store anything in that as long as you omit the reserved fields:
class SomeModel(db.Expando):
pass
your_model = SomeModel()
for k, v in your_dict.iteritems():
setattr(your_model, k, v)
也许可以使用
your_model.__dict__.update(your_dict)
,但我不确定。Store it in a textfield using pickle:
class SomeModel(db.Model):
pickled_data = db.BlobProperty()
your_model = SomeModel()
your_model.pickled_data = pickle.dumps(your_dict)