1👍
✅
Just put disease object out in the request POST
def drui(request):
disease_id = request.GET.get('disease_id', '2')
disease = get_object_or_404(Disease, pk=disease_id)
if request.method == "POST":
diseaseForm = DiseaseForm(request.POST, instance=disease)
if diseaseForm.is_valid():
new_disease = diseaseForm.save(commit=False)
indicatorInlineFormSet = IndicatorFormSet(request.POST, request.FILES,
instance=new_disease)
if indicatorInlineFormSet.is_valid():
new_disease.save()
indicatorInlineFormSet.save()
return HttpResponseRedirect(reverse(somewhere))
else:
diseaseForm = DiseaseForm(instance=disease)
indicatorInlineFormSet = IndicatorFormSet(instance=disease)
return render_to_response("drui.html", {
'diseaseForm': diseaseForm,
'indicatorInlineFormSet': indicatorInlineFormSet
},context_instance=RequestContext(request))
Source:stackexchange.com