一、dict存入model instance
data_dict是{}字典数值
# create instance of model m = MyModel(**data_dict) # don‘t forget to save to database! m.save()# create instance of model m = MyModel(**data_dict) # don‘t forget to save to database! m.save()
如果数据库还有特定的列,extra, extra2,不在字典里,可以单独添加,**dict必须放在最后
m2 =MyModel(extra=‘hello‘, extra2=‘world‘, **data_dict) m2.save()
踩
(0)
赞
(0)
举报
评论 一句话评论(0)