def updateTheme(self, id, new_theme):
theme = Theme.query.filter_by(id = id).first()
theme.update(new_theme)
db.session.commit()
错误:“主题”对象没有属性“更新”
这是它应该如何工作:
theme = Theme(name = "osman")
new_theme = Theme(name = "miras")
theme.update(new_theme)
print(theme) # osman have to be changed to miras
即使我可以这样做:
theme.name = "miras"
当我必须使用多个参数时,如姓名、姓氏、电话。此外,updateTheme 并不总是提供所有参数(姓名、姓氏、电话),它应该只更新提供的参数。例如:
person = {name: "john", surname: "smith", phone: 12345, country: "USA"}
update_person = {country: "Portugal"}
person.update(update_person) # should change only country
相关分类