javascript - 有没有办法从 html 文档中的数据库中删除对象?(django)
问题描述
视图.html
<th><button id={{p.id}} onclick="Delete(this.id)" class="btn btn-outline-danger">Delete</button></th>
<script>
function Delete(row_id){
document.getElementById(row_id).remove();
{{dogss.objects.filter(id=1)}.delete()}} //I wanted this to happen, but it's not working
}
</script>
</tr>
视图.py
def view(response):
return render(response, "main/view.html", {"dogs": Dog.objects.filter(user=response.user), "dogss": Dog})
我知道我可以使该按钮与 .py 文件交互,并且从那里它可能会起作用。但我很好奇为什么这不起作用?
解决方案
推荐阅读
- angular - 打字稿(Angular)订阅
- sqlite - SQLite:将不存在的列视为 NULL
- r - 使用 as.POSIXct 将日期从“字符”格式转换为“POSIXct”时 1 个特定日期的 NA
- c# - 无法在统一内旋转矢量
- scala - : => 方法参数声明中的语法是什么意思?
- maps - 如何从 OSM 下载特定区域
- php - Cookies 功能不保存数据
- scala - Travis CI Scala Play 应用程序构建和部署优化
- react-native - React-native - 如何创建一个可滚动的 flatList,其中所选项目位于中间?
- signal-processing - System.Web.HttpContext.Current.get 返回 null - 网站项目 [SignalR]