Python ı;想将两个id从.html发布到视图吗

Python ı;想将两个id从.html发布到视图吗,python,django,url,Python,Django,Url,html文件ı想将两个id带到views.py可以获取它吗 path('yorum_sil/<int:id>',views.yorum_sil,name="yorum_sil") 路径('yorum_-sil/',views.yorum_-sil,name=“yorum_-sil”) 我想这样做的代码如下 path('yorum_sil/<int:comment_id> and <int:post_id>',views.yorum_sil,name="yo

html文件ı想将两个id带到views.py可以获取它吗

path('yorum_sil/<int:id>',views.yorum_sil,name="yorum_sil")
路径('yorum_-sil/',views.yorum_-sil,name=“yorum_-sil”) 我想这样做的代码如下

path('yorum_sil/<int:comment_id> and <int:post_id>',views.yorum_sil,name="yorum_sil")
path('yorum\u-sil/and',views.yorum\u-sil,name=“yorum\u-sil”)

这是可能的,但不应使用这样的空格。例如,可以使用斜线,如:

path('yorum_sil/<int:comment_id>/<int:post_id>',views.yorum_sil,name="yorum_sil")
如果执行反向查找,则需要传递这两个参数。例如,在以下模板中:

<a href="{% url 'yorum_sil' comment_id=14 post_id=25 %}">some_link</a>

如果我正确翻译了yorum sil,这意味着删除注释,请注意,通常GET请求不应有副作用。为了删除/创建/。。。一个实体,你应该使用POST请求。

什么不起作用?path('yorum_-sil/and',views.yorum_-sil)写了,这里只是为了让你能理解,但我认为用法不像'str'对象没有属性'get',我在程序运行返回反向函数时遇到了这个错误,而ı写了返回反向函数,比如return reverse(“detay”,kwargs={“id”:commentİid})@İsaGİRİRŞKEN:在这个特定视图中,您应该编写
返回重定向(“detay”,id=comment_id)
。但这与这个URL无关,每个视图都应该返回HTTP响应,而不是字符串。@segİsaGİRİKEN KEN:不要执行
重定向(反向(…)
,您可以使用
重定向('view_name',some_参数=some_值)
,这更快捷、更优雅、更安全。
<a href="{% url 'yorum_sil' comment_id=14 post_id=25 %}">some_link</a>