我想把Goods中desc_detail在原字段基础上更改,请问如何批操作?
class Goods:
desc_detail =CharField(max_length=100)
good_ = Goods.objects.all()
for i in good_:
i.desc_detail = site_replace( i.desc_detail )
i.save()
def site_replace(STR):
return STR.replace('ori', 'new')
已知:
把"desc_detail"字段改为固定值操作如下: Goods.objects.update(desc_detail = "default");
而Goods.objects.update(desc_detail = site_replace(desc_detail) ) 报错: desc_detail not defined.