I have postgres function
DECLARE office_lastnumber TEXT;
BEGIN
UPDATE curriculum.clearance_item SET resolve=TRUE,resolve_date=now() where cl_itemid=f_cl_itemid;
INSERT INTO curriculum.transaction_log (cl_itemid,trans_desc,trans_recorded)
VALUES (f_cl_itemid,'Resolved Clearance Item',now());
RETURN f_cl_itemid;
END;
I have this list of items, cut some rows so it's easier to read
<table style="width:100%">
<tr>
<th>cl_itemid</th>
<th colspan="2">Actions:</th>
</tr>
{%for data in data%}
<tr>
<td>{{data.cl_itemid}}</td>
<td><a href="{% url 'update' data.cl_itemid %}">Update</a></td>
</tr>
{%endfor%}
</table>
And views.py
def update(request):
if request.method == "POST":
cursor = connection.cursor()
resolve_item = # what to put here
cursor.execute("select resolve_clearance_item('"+resolve_item+"')")
return render(request, 'clearance/index.html')
else:
return render(request, 'clearance/index.html')
cl_itemid
OSA2022-2023 | update
DORM2022-2023| update
How can def update knows if I click update (ex.OSA2022-2023) then it puts in resolve_item and run the function