title: how to access request data sent as form-data to Django rest framework
body: <p>I'm sending a POST request with a body as FormData from my <code>flutter</code> application to my <code>Django</code> backend.. the body has both <code>MultiPart Files</code> and <code>String</code> but when I try to access data in my backend some of them are not accessible .. here is my code :</p>
  <p><strong>flutter form-data body</strong></p>
  <pre class="lang-dart prettyprint-override"><code>    FormData form = FormData({
        &quot;mobile_number&quot;: supplierMobileController.text,
        &quot;password&quot;: supplierPasswordController.text,
        &quot;firebase_token&quot;: &quot;123456789&quot;,
        &quot;main_user&quot;: {
          &quot;username&quot;: supplierMobileController.text,
          &quot;password&quot;: &quot;123456789&quot;
        },
        &quot;client_object&quot;: null,
        &quot;supplier_object&quot;: {
          &quot;personal_name&quot;: supplierPersonalNameController.text,
          &quot;company_name&quot;: supplierCompanyNameController.text,
          &quot;email&quot;: supplierEmailController.text,
          &quot;established&quot;: supplierMonthController.text.length == 2
              ? &quot;${supplierYearController.text}-${supplierMonthController.text}-01&quot;
              : &quot;${supplierYearController.text}-0${supplierMonthController.text}-01&quot;,
          &quot;number_of_projects&quot;: supplierNumberOfProjectsController.text,
          &quot;tax_id&quot;: MultipartFile(File(imageOne.value),
              filename: &quot;${supplierCompanyNameController.text}_tax_image.png&quot;),
          &quot;company_logo&quot;: MultipartFile(File(imageTwo.value),
              filename: &quot;${supplierCompanyNameController.text}_logo_image.png&quot;),
          &quot;business_register&quot;: MultipartFile(File(imageThree.value),
              filename:
                  &quot;${supplierCompanyNameController.text}_business_image.png&quot;),
          &quot;company_text&quot;: &quot;&quot;
        },
      });
  </code></pre>
  <p>and this is how am trying to access this data in the backend :</p>
  <p><em><strong>Django Backend function</strong></em></p>
  <pre class="lang-py prettyprint-override"><code>@permission_classes([&quot;AllowAny&quot;])
  @parser_classes([&quot;JSONParser&quot;])
  @api_view(['POST'])
  def create_new_supplier(request):
      '''
      Handles API call to create a new supplier
      '''
      data = {}
      if request.method == 'POST':
          main_user_serializer = MainUserSerializer(data=request.data['main_user']) # causes an error
          main_user_serializer.is_valid(True)
          main_user_data = main_user_serializer.data
          app_user_serializer = AppUserSerializer(data=request.data)
          app_user_serializer.is_valid(True)
          validated_data = app_user_serializer.data
          supplier_serializer = models.Supplier(data=request.data['supplier_object'])
          supplier_serializer.is_valid(True)
          supplier_object_data = supplier_serializer.data
          main_user_object = User.objects.create_user(**main_user_data)
          app_user = models.AppUser.objects.create(**validated_data)
          token_object = Token.objects.create(user=main_user_object)
          supplier_object = models.Supplier.objects.create(**supplier_object_data)
          app_user.token = token_object
          app_user.client_object = None
          app_user.supplier_object = supplier_object
          app_user.main_user = main_user_object
          app_user.is_active = False
          app_user.save()
          data = {
              &quot;success&quot; : True,
              &quot;details&quot;:AppUserSerializer(app_user).data,
          }
          return Response(data, headers=get_headers())
  
  </code></pre>
  <p>the line <code>main_user_serializer = MainUserSerializer(data=request.data['main_user'])</code> causes this error :</p>
  <pre><code>    raise MultiValueDictKeyError(key)
  django.utils.datastructures.MultiValueDictKeyError: 'main_user'
  </code></pre>