gpt4 book ai didi

html - Django 表单实践

转载 作者:太空宇宙 更新时间:2023-11-04 15:42:23 26 4
gpt4 key购买 nike

当用户点击一个简单的链接时,我可以模拟类似表单的行为吗?

例如,我可以在 views.py 中有吗

def remove(request, entity_id):
#remove the object with entity_id here

在 HTML 中

<a href="profile/remove/{{ obj.entity_id }}">

在 urls.py 中

(r'^app/profile/remove/(?P<entity_id>\d+)', 'app.views.remove')

或者我必须使用像 tutorial 中那样的适当的 HTML 表单吗? ?

最佳答案

GET/HEAD 请求不应该有任何有害的副作用(来自 HTTP 1.1 spec, 9.1:“特别是,已经建立的约定 GET 和 HEAD 方法不应该具有采取除检索之外的操作的意义。” ),这就是 POST/PUT/DELETE 方法的用途。

除此之外 - Django 不会禁止在 GET 请求时从数据库中删除一行,如果这是你的要求的话。

关于html - Django 表单实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1405450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com