我试图将表单集中每个表单的值设置为单个值。我不知道如何完成这个...views.py 函数如下:喜欢: formset.idcst_cnt = idviews.pydef customer_contacts(request, id): ContactFormSet = modelformset_factory(AppContactCnt, can_delete=True, fields=( 'name_cnt', 'phone_cnt', 'email_cnt', 'note_cnt', 'receives_emails_cnt'), max_num=3, extra=3) formset = ContactFormSet(queryset=AppContactCnt.objects.filter(idcst_cnt=id), prefix='contact') if request.method == 'GET': context = {'formset': formset} return render(request, 'customer_contacts.html', context=context) if request.method == 'POST': formset = ContactFormSet(request.POST, prefix='contact') if formset.is_valid(): print("we're updating contacts for " + str(id)) # formset.save() return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
添加回答
举报
0/150
提交
取消