How to go to the page for editing the same record immediately after saving the record

Hi! On the page with the form, I add a new record to the table and immediately want to go to another page to edit the same record. How do I pass the id of this record and call the page for editing?
My view:

def JurnalOst(request):
    podraz = Podraz.objects.get(pk=74)
    postav = Postav.objects.get(pk=9)
    obct = Obct.objects.get(pk=180)
    fio = Fio.objects.get(pk=5)
    jurnalost=Jurnal.objects.filter(oper=1)
    if request.method=='POST':
        form=OstDocForm(request.POST)
        if form.is_valid():
            form.save()
            print('Save')
            last_id = Jurnal.objects.latest('id')
            print(last_id)
            #What's here?
            ################?
    else:
        form=OstDocForm(initial={'podraz':podraz,'postav':postav,'obct':obct,'fio':fio})
      
    return render(request,'store/Doc/JurnalOst.html',{'form':form})

I want to get the same record: last_record=Jurnal.objects.get(pk=last_id) and go to the page to edit it. How to transmit this last_id?
Thanks!

Solution found, thanks

For the benefit of those coming along later, would you like to post your solution?

1 Like