I am working on a project in django and I have the following problem I have a list of products in a table, which belong to a common list (list with id 26), as seen in the following image:
Now I need that when you click on the "add product" button, you can pass the id from the list (26) to a new product.
I had tried in the following way to pass the id the list to the form that I need, but I can not pass it: in my views.py
def getid(request, id):
li = Lista.objects.get(id=id)
return render(request, 'core/form_producto.html', {
'li':li
})
and in my urls.py
path('form_producto/<id>/', form_producto, name="form_producto"),
and finally pass it to the template of the new product form in the list ...
<input type="text" name="txtid" id="txtid" value="{{ li.id }}">
How could I solve this? thank you very much