def edit_consult(request, edit_id): obj = models.ConsultRecord.objects.filter(pk=edit_id).first() form_obj = ConsultForm(instance=obj) if request.method == 'POST': form_obj = ConsultForm(request.POST, instance=obj) if form_obj.is_valid(): form_obj.save() return redirect(reverse('consult_list', args=('0',))) return render(request, 'consultant/edit_consult.html', {'form_obj': form_obj})
def edit_consult(request, edit_id): obj = models.ConsultRecord.objects.filter(pk=edit_id).first() form_obj = ConsultForm(instance=obj) title = '编辑跟进记录' if request.method == 'POST': form_obj = ConsultForm(request.POST, instance=obj) if form_obj.is_valid(): form_obj.save() return redirect(reverse('consult_list')) return render(request, 'form.html', {'form_obj': form_obj, 'title': title})
def add_consult(request): obj = models.ConsultRecord(consultant=request.user_obj) form_obj = ConsultForm(instance=obj) title = '添加跟进记录' if request.method == 'POST': form_obj = ConsultForm(request.POST, instance=obj) if form_obj.is_valid(): form_obj.save() return redirect(reverse('consult_list')) return render(request, 'form.html', {'form_obj': form_obj, 'title': title})
def add_consult(request): obj = models.ConsultRecord(consultant=request.user_obj) form_obj = ConsultForm(instance=obj) if request.method == 'POST': form_obj = ConsultForm(request.POST, instance=obj) if form_obj.is_valid(): form_obj.save() return redirect(reverse_url(request, 'consult_list')) return render(request, 'add_consult.html', {'form_obj': form_obj})
def consult_edit(request, edit_id): # 查询出要编辑的对象 obj = models.ConsultRecord.objects.filter(pk=edit_id).first() form_obj = ConsultForm(instance=obj) # 处理POST请求 if request.method == 'POST': # 实例化一个带提交参数的form form_obj = ConsultForm(request.POST, instance=obj) # 校验数据 if form_obj.is_valid(): form_obj.save() # 新增 return redirect(reverse('consult_list', args=('0'))) return render(request, 'consultant/consult_edit.html', {'form_obj': form_obj})
def consult_add(request): # 实例化一个包含当前销售的跟进记录 obj = models.ConsultRecord(consultant=request.account) form_obj = ConsultForm(instance=obj) # 处理POST请求 if request.method == 'POST': # 实例化一个带提交参数的form form_obj = ConsultForm(request.POST, instance=obj) # 校验数据 if form_obj.is_valid(): form_obj.save() # 新增 return redirect(reverse('consult_list', args=('0'))) return render(request, 'consultant/consult_add.html', {'form_obj': form_obj})
def consult_add(request): form_obj = ConsultForm() return render(request, 'consult_add.html', {'form_obj': form_obj})