views.py
def form_demo_update(request,profile_pk):
profile = get_object_or_404(Createdemo,pk=profile_pk)
if request.method == "POST":
form = Form_demo(request.POST or None, instance=profile)
# success_url = reverse_lazy ('profile_update') #success_msg = 'Ok'
if form.is_valid():
#instance=form.save(commit=False)
form.save()
return redirect('/')
context={
'form':form,
'profile':profile,
}
return render(request,'travel_form.html',context)
urls.py
path('updateprofile/<profile_pk>',views.form_demo_update,name='update_profile'),
обновление. html
<form action="{%url 'update_profile' profile.pk %}" method="post">
{% csrf_token %}
{{form}}
<input type="submit" value="Update" />
</form>