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']我将得到一个空数组,请求类型是多份表单数据