【发布时间】:2015-12-17 03:40:36
【问题描述】:
我目前是 Django 和 Web 开发的新手。
我在 HTML 模板中显示了一些数据。数据采用表格行格式。用户可以从每一行编辑数据(从文本和下拉菜单)。我想调用 django 视图以在单击与该行关联的按钮时更新相应模型数据库中的该行数据。
这是我的 HTML 代码:
<table>
<tr>
<th>Candidate Name </th>
<th>Change Application Status </th>
<th>Submit </th>
</tr>
{% for eachApplication in myCompanyApplications %}
<td>
<a href="/candidate/{{ eachApplication.candidateId }}/">{{ eachApplication.candidateName }}</a></td>
<td>
<select>
{% for choice in list.currentApplicationStatus %}
<option {{choice.0}}>{{choice}}</option>
{% endfor %}
</select>
</td>
<td><input type="submit" class="btn" value="Commit" name="mybtn"></td>
</tr>
{% endfor %}
</table>
我想检测变化(applicationStatus change etc)
单击一个按钮应该调用一个视图,并且该视图将更改相应的Django model
如果有更好的方法请提及。
我们将不胜感激。
谢谢:)
【问题讨论】:
标签: jquery python html django django-models