首页 > 解决方案 > 如何在 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

标签: django

解决方案


推荐阅读