title: How to properly upload images when also sending data to the server
body: <p>I have implemented an view that is for registering an organization. How do I successfully upload files given the following payload:</p>
  <pre><code>{
  &quot;admin&quot;:{
          &quot;username&quot;:&quot;kapyjovu@abyssmail.com&quot;,
          &quot;first_name&quot;:&quot;Cindy&quot;,
          &quot;last_name&quot;:&quot;Georgia&quot;,
          &quot;password&quot;:&quot;password&quot;,
          &quot;email&quot;:&quot;kapyjovu@abyssmail.com&quot;
      },
  &quot;org&quot;:{
          &quot;name&quot;:&quot;ARIZONA LAW SOCIETY&quot;,
          &quot;short_name&quot;:&quot;ALS&quot;,
          &quot;tag_line&quot;:&quot;ALS&quot;,
          &quot;email&quot;:&quot;kapyjovu@abyssmail.com&quot;,
          &quot;company_phone&quot;: &quot;+2540000000&quot;,
          &quot;po_box&quot;: &quot;200&quot;,
          &quot;location&quot;:&quot;NAKURU&quot;,
          &quot;first_logo&quot;: &quot;https://www.mintformations.co.uk/blog/wp-content/uploads/2020/05/shutterstock_583717939.jpg&quot;,
          &quot;second_logo&quot;: &quot;https://www.mintformations.co.uk/blog/wp-content/uploads/2020/05/shutterstock_583717939.jpg&quot;,
          &quot;third_logo&quot;: &quot;https://www.mintformations.co.uk/blog/wp-content/uploads/2020/05/shutterstock_583717939.jpg&quot;
      }
  }
  </code></pre>
  <pre><code>class OrganizationRegistration(generics.CreateAPIView):
      queryset = Organization.objects.all()
      permission_classes = (permissions.AllowAny,)
      serializer_class = OrgRegistrationSerializer
  
      &quot;&quot;&quot;End point to register organization&quot;&quot;&quot;
  
      def post(self, request, format=None, *args, **kwargs):
          try:
              admins = Group.objects.get(name__iexact='admin')
              admin_role = Role.objects.get(name__iexact=&quot;admin&quot;)
              
          except:
              # the admin group is
              admins = Group.objects.create(name=&quot;admin&quot;)
  
              admin_role = Role.objects.create(name=&quot;admin&quot;)
  
             
          # finally:
          try:
              admin = User.objects.create(
                  username=request.data['admin']['username'],
                  email=request.data['admin']['email'],
                  first_name=request.data['admin']['first_name'],
                  last_name=request.data['admin']['last_name'],
              )
  
  
              
              location_name = request.data['org']['location'].upper()
          
              location_obj, _  = Location.objects.get_or_create(name=location_name)
              area_name = location_obj.name
          except Exception as e:
              # print(e)
              return Response(data={&quot;msg&quot;:str(e),&quot;success&quot;:False, &quot;data&quot;: None},status=status.HTTP_400_BAD_REQUEST)
          # admin.set_password(request.data['admin']['password'])
  
  
          try: 
  
              
              # Create Random Password   
              password = User.objects.make_random_password(length=10)
              admin.set_password(password)
              admin.save()
              # add the user creating the Organization to the admin group
              # admins.user_set.add(admin)
              admin.groups.add(admins)
              admin.roles.add(admin_role)
  
  
              first_file_logo = request.data['org']['first_logo']
              second_file_logo = request.data['org']['second_logo']
              third_file_logo = request.data['org']['third_logo']
  
              org = Organization.objects.create(
                  name=request.data['org']['name'],
                  email=request.data['org']['email'],
                  location=request.data['org']['location'],
                  short_name = request.data['org']['short_name'],
                  tag_line = request.data['org']['tag_line'],
                  company_phone =  request.data['org']['company_phone'],
                  po_box = request.data['org']['po_box'],
                  first_logo = first_file_logo,
                  second_logo =second_file_logo ,
                  third_logo =  third_file_logo
              )
  
              
              admin.org_id = org.id
              admin.save()
              # add the user creating the Organization to admins by DEFAULT
              # NOTE:
              # all the other normaall users will be added normally i.e
              admins.save()
              org.admin.add(admin)
              org.user_set.add(admin)
              admin.is_active = False
              admin.save()
              payload = jwt_payload_handler(admin, org)
              jwt_token = jwt_encode_handler(payload)
              support_email = settings.SUPPORT_EMAIL
              # # FIXME:
              # refactor this code inorder to have its own function
              path = get_full_path(request)
  
              path = settings.BASE_URL
              subject = 'Welcome onboard E-vote'
              # if the org is regestering themselves the org id will alway be zero
              message = 'Follow\n {}sso/registration/confirmation/{}/ \nto complete \
                  the sign-up process. \nAfter Confirmation your Login Password is: {}'.format(
                  path, jwt_token.decode(&quot;utf-8&quot;),password)
  
              # print(path+'/api/sso/registration/confirmation/{}'.format(jwt_token.decode(&quot;utf-8&quot;) ))
              # invitation sent to organization
              mail_sent_to_org = send_mail(
                  subject,
                  message,
                  support_email,
                  [org.email]
              )
  
              message = 'Follow\n{}sso/registration/confirmation/{}/ \nto complete \
                  the sign-up process. \nAfter Confirmation your Login Password use this Password: {}'.format(
                  path, jwt_token.decode(&quot;utf-8&quot;) ,password)
              # invitation sent to admin
              mail_sent_to_admin = send_mail(
                  subject,
                  message,
                  support_email,
                  [admin.email]
              )
              serializer = OrgRegSerializer(org)
              res = {&quot;msg&quot;: &quot;Check personal and organization emails, NOTE: finish org registration first!!!&quot;, &quot;success&quot;: True, &quot;data&quot;: serializer.data}
              return Response(
                  data=res,
                  status=status.HTTP_201_CREATED
              )
          except Exception as e:
              return Response(data={&quot;msg&quot;:str(e),&quot;success&quot;:False, &quot;data&quot;: None},status=status.HTTP_400_BAD_REQUEST)
  
  </code></pre>
  <p><strong>Models</strong></p>
  <pre><code>class Organization(Group):
      email = models.EmailField(max_length=60, blank=False, null=False)
      admin = models.ManyToManyField(settings.AUTH_USER_MODEL)
      users = models.ManyToManyField(settings.AUTH_USER_MODEL,related_name='org_users')
      is_active = models.BooleanField(default=False)
      short_name = models.CharField(max_length=200,blank=True)
      location = models.CharField(max_length=200,blank=True, null=True)
      tag_line = models.TextField(null=True,blank=True)
      company_phone =  models.CharField(max_length=15, blank=True, null=True)
      po_box = models.CharField(max_length=15, blank=True, null=True)
      first_logo = models.ImageField(null=True,blank=True)
      second_logo = models.ImageField(null=True,blank=True)
      third_logo = models.ImageField(null=True,blank=True)
      history = HistoricalRecords()
  </code></pre>