[Fixed]-In the edit form of Django CRUD application the existing data is not showing correctly in the fields

1👍

I expect you meant to use the instance, server, not the class, Proposal, as the instance value.

form = ProposalForm(request.POST or None, instance=server)

0👍

Use initial keyword to populate your form. Maybe something on this line may help.

def proposal_update(request, pk,template_name='proposal/proposal_form.html'):
server = get_object_or_404(Proposal, pk=pk)

data = {'template_field_name': model_field_name}
form = MyForm(initial=data)

if form.is_valid():
    form.save()
    return redirect('list')
return render(request, template_name, {'form':form})
👤DeA

Leave a comment