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')
效果很好 有人可以解释一下吗?感谢