1👍
✅
I think you should try to filter by id instead of the so_hd so you would go about it like this in your view:
def chi_tiet_hop_dong(request,so_hd):
contract=testimport.objects.filter(id=so_hd)
print("số hợp đồng trong def chi tiết hợp đồng",so_hd)
request.session["save_so_hd"]=json.loads(json.dumps(so_hd))
lst_contract=request.session["get_contract_detail"]
try:
the_next = lst_contract[lst_contract.index(so_hd) + 1]
print("the next",the_next)
except:
the_next=None
try:
the_prev=lst_contract[lst_contract.index(so_hd) - 1]
print("the prev",the_prev)
except:
the_prev=None
baocao=report.objects.filter(id=so_hd)
form=AddReportForm()
return render(request, "caller_template/contract_detail.html", {"contract":contract,"the_next":the_next,"the_prev":the_prev,"baocao":baocao,"form":form})
Source:stackexchange.com