django - 如何在 django Templates href 中使用 vue 对象的数据
问题描述
我想使用django模板href模式构造一个url,但问题是url必须包含来自vue对象的数据。在我的 Vue 对象中,我使用${}来避免与 django 的分隔符冲突,所以我尝试像这样构造 url:
{%url 'main:commodityInfoPage' %{task.category} %{task.searchKey} %}
这部分的整个代码是这样的:
<tr v-for="task in taskList">
<td>${task.searchKey}</td>
<td>${task.category}</td>
<td>${task.taskId}</td>
<td>${task.status}</td>
<td><a href="{%url 'main:commodityInfoPage' %{task.category} %{task.searchKey} %}">Info</a></td>
</tr>
我的 django 路由器是这样的:
path('commodityInfo/<str:category>/<str:searchKey>/',views.commodityInfoPage, name = 'commodityInfoPage')
不幸的是,它不起作用。现在我知道这是关于参数%{task.category},%{task.searchKey}。但是我不知道如何正确设置格式,您能告诉我如何解决吗?