javascript - 如何使用 Django 中的表单在视图中发布运行时数据
问题描述
我使用ajax在特定的div部分写入数据,现在我想在views.py中发布这些数据,但它返回None。<input type='checkbox' id='filesid' name = 'filesname' value='abc'>
当我像abc一样手动写作时。它返回值。jquery 也适用于此。html代码
html_code = "<input type='checkbox' id='filesid' name = 'filesname' value='"+i+"'>"+i+"<br>"
$('#runtime-div').html(html_code);
另一个使用表单的 html 页面
<form action = '/home/update_file/' id="UpdateDataFiles" method="post" enctype="multipart/form-data" onsubmit="return myUpdateFile()">
{% csrf_token %}
<div id='runtime-div' class="card-body">
</div>
</form>
视图.py
filename = request.POST.get('filesname')
print(filename)
解决方案
推荐阅读
- angularjs - How to disable (or escape) interpolation in a DOM attribute?
- visual-studio-code - 如果打开,是否有 VSCode 操作来关闭侧边栏,否则什么都不做?
- mysql - 创建新列和比较
- html - 源代码中的换行符在右对齐并使用时呈现为无宽度空白
- python - 合并列、pickup_date 和pickup_time = + 不支持的操作数类型:“DatetimeIndex”和“str”
- node.js - 我可以使用 Mongo DB 设置服务器以使用 three.js 库进行开发吗?
- python - 如何在 pandas 数据帧上生成具有随机值的合成数据?
- android - 我们如何使用 setLaunchDisplayId() 将 Activity 显示为横向?
- spring-boot - Spring Security 5 OpenId 资源服务器 Websecurity dsl
- javascript - JavaScript 中是否有一种方法可以在相对较快的时间内获得大量 BigInt 类型的表示?