社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Django

django如何更新项目

Michael • 2 年前 • 1312 次点击  

我有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 ]  |  最新文章 2 年前