Py学习  »  Django

django如何更新项目

Michael • 3 年前 • 1345 次点击  

我有postgres函数

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;

我有这个项目列表,剪切一些行,这样更容易阅读

    <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>

和视图.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 |更新

DORM022-2023 |更新

怎么可能 def更新 知道如果我点击更新(例如OSA2022-2023),它会放入resolve_item并运行函数

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/159478
文章 [ 1 ]  |  最新文章 3 年前