【发布时间】:2021-10-19 07:02:47
【问题描述】:
我有如下超链接的 html 代码:
<td> <a href="{% url 'select_stock_report' book.id %}">{{ book.code }}</a></td>
<td>{{book.name}}</td>
它正在指向正确的页面。
在来自响应的脚本中,我将页面更新如下它没有给出错误(当然链接页面是空的,因为 1 作为参数):
html += "<tr> <td> <a href= '{% url 'select_stock_report' 1 %}'>"+item1.code+"</a></td>"+
"<td>" + item1.name + "</td>" + "<td>" + item1.open_qty + " </td>"
但我想用 item1.id 替换 1(一)。
html += "<tr><td><a href='{% url 'select_stock_report' item1.id %}'>"+item1.code+"</a></td>"+
"<td>" + item1.name + "</td>" + "<td>" + item1.open_qty + " </td>"
但我遇到了错误。
如何用这个替换建立生产线。我用这个 item.id 尝试了所有的 "",'',+ 没有成功。
感谢您的帮助。
【问题讨论】:
-
究竟什么是
item1?Book对象? -
是的,它是书籍对象; item1.id =book.id; item1.code=book.code
-
你能分享一下你遇到了什么错误吗?
-
html += "
"+item1.code+" " + "" + item1.name + " " + "" + item1.open_qty + " "Django 版本:3.1.1 异常类型:NoReverseMatch 异常值:“select_stock_report”的反向参数“(”,)“未找到。尝试了 2 种模式:['listselectstktrans/(?P[0-9]+)/$', 'wstore/listselectstktrans/(?P [0-9]+)/$']
标签: javascript python html django response