title: Django Rest Framework: Loop inside JSON OBJECT
body: <p>Hi Guys I'm new to Django and Python... I'm using REST Framework to develop some webservices. I want to loop through all the orders of a JSON item. The request from javascript is done in this way: </p>
  
  <pre><code>    function TestDjangoPostWithNoCsrlTokenAndWithMultipleObjectsJson() {
  
      var JSONObject = new Object();
      JSONObject.Orders = [];
      JSONObject.Orders.push({ id: 1, Name: 'Name1', Description: 'Description1' });
      JSONObject.Orders.push({ id: 2, Name: 'Name2', Description: 'Description1' });
      JSONObject.Orders.push({ id: 3, Name: 'Name3', Description: 'Description1' });
      console.log(JSON.stringify(JSONObject));
      $.ajax
    ({
        type: "POST",
        url: URL_PostOrdersMultipleObjects,
        headers: {
            "Authorization": "Basic " + btoa("xxx" + ":" + "xxx")
        },
        data: JSONObject,
        dataType: 'json',      
  
        success: function (data, status, xhr) {
         console.log(JSON.stringify(data));
            if (xhr.readyState == 4) {
                if (xhr.status == 201) {
                    console.log("Created");
                }
            } else {
                console.log("NoGood");
            }
        },
        complete: function (xhr) {
        },
        error: function (xhr, ajaxOptions, thrownError) {
            console.log(xhr.status);
            console.log(thrownError);
        }
    });
  
  
  }
  </code></pre>
  
  <p>On Django side, I have...</p>
  
  <pre><code>  @api_view(['GET', 'POST'])
  def JSONPostTest(request):
      if request.method == 'POST':  
          stream = io.BytesIO(request.body)
          obj = JSONParser().parse(stream)  
  
          for order in obj['Orders']:     # First Example
  
              serializer = QASerializer(data=order)
              if serializer.is_valid():
                 serializer.save()
              else :
                 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)   
  
          return Response('OK', status=status.HTTP_201_CREATED)           
      else:
          return Response('OK', status=status.HTTP_201_CREATED) 
  </code></pre>
  
  <p>If In javascript i stringify my object before to send it the above code works fine. The problems is when I don't stringify.</p>
  
  <p>If I stringify </p>
  
  <pre><code>request.body = 
  b'{"Orders":[{"id":1,"Name":"Name1","Description":"Description1"},{"id":2,"Name":"Name2","Description":"Description2"},{"id":3,"Name":"Name3","Description":"Description3"}]}'
  </code></pre>
  
  <p>if I don't stringify </p>
  
  <pre><code>request.body
  b'Orders%5B0%5D%5Bid%5D=1&amp;Orders%5B0%5D%5BName%5D=Name1&amp;Orders%5B0%5D%5BDescription%5D=Description1&amp;Orders%5B1%5D%5Bid%5D=2&amp;Orders%5B1%5D%5BName%5D=Name2&amp;Orders%5B1%5D%5BDescription%5D=Description1&amp;Orders%5B2%5D%5Bid%5D=3&amp;Orders%5B2%5D%5BName%5D=Name3&amp;Orders%5B2%5D%5BDescription%5D=Description1'
  </code></pre>
  
  <p>and </p>
  
  <pre><code>request.data
  &lt;QueryDict: {'Orders[1][Description]': ['Description1'], 'Orders[2][id]': ['3'], 'Orders[0][Name]': ['Name1'], 'Orders[0][Description]': ['Description1'], 'Orders[2][Description]': ['Description1'], 'Orders[1][id]': ['2'], 'Orders[0][id]': ['1'], 'Orders[1][Name]': ['Name2'], 'Orders[2][Name]': ['Name3']}&gt;
  </code></pre>
  
  <p>I can stringify no problem on that. But I want to understand if it's possible to obtain the same result without stringifing starting from the QueryDict I have.</p>
  
  <p>Thank you</p>