django - 如何在 django 中使用 request.POST[] 请求对象数组
问题描述
for c in request.POST['colors']:
col=Colors()
col.color=c['name']
col.main_id_id=article.id
col.save()
if request.POST['is_dimension']:
for wbd in (request.POST['dimension']:
dim=Dimensions()
dim.width=wbd['width']
dim.breadth=wbd['breadth']
dim.depth=wbd['depth']
dim.main_id_id=article.id
dim.save()
在上面的代码中,如果我使用 request.POST.getlist('colors') 而不是这个 request.POST['colors'] 我将得到空数组,REQUEST TYPE IS MULTIPART FORM DATA
解决方案
推荐阅读
- sql-server - 通过从 SQL Server 中的行截断/删除类似信息来转换数据
- c# - 使用反射调用具有泛型类型参数的泛型方法
- python - 在 Celery 任务之间共享一个变量
- android - 使用 FusedLocationProviderClient 在 Lollipop Emulator 上不调用 onLocationCallback
- c# - 实体框架在获取 DateTime 时抛出异常
- wordpress - Cloudways WP 安装上的 SSL 证书问题
- angular - 动态创建组件——“ng build --prod”在创建包时抛出错误
- dart - Web 请求后,导航到其他视图(async /await 正确使用)- Flutter , dart
- webrtc - https://webrtc.github.io/samples/ 上的 WebRTC 示例应该做什么?
- regex - 过滤内容,但不删除找到的组