save()之后django模型实例的属性不会改变

时间:2013-10-09 08:03:10

标签: python django django-models

def post(self, request, *args, **kwargs):
    self.company.name = request.POST['company_name']
    self.company.certification = request.POST['company_pic_url']
    self.company.save()
    return http.HttpResponseRedirect('/company')

这里,company是一个模型实例,名称和认证在save()

之后不会改变

然而

def post(self, request, *args, **kwargs):
    company = self.company
    company.name = request.POST['company_name']
    company.certification = request.POST['company_pic_url']
    company.save()
    return http.HttpResponseRedirect('/company')

效果很好 有人可以解释一下吗?感谢

0 个答案:

没有答案