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!