这是一个创建于 3577 天前的主题,其中的信息可能已经有所发展或是发生改变。
照http://simplectic.com/blog/2014/flask-todomvc-sqlalchemy/ 上面的例子 要对每个表字段挨个配置一遍
def to_json(self):
return {
"id": self.id,
"title": self.title,
"order": self.order,
"completed": self.completed}
def from_json(self, source):
if 'title' in source:
self.title = source['title']
if 'order' in source:
self.order = source['order']
if 'completed' in source:
self.completed = source['completed']
除了这种方式,还有别的简单一点的办法吗?