title: Django How to format JSON response from drf API?
body: <p>I would like to know how to modify the way I represent the JSON Response of my requests to the API created with DRF, tabs, spaces, etc..., in order to respond exactly to my frontend app.</p>
  <p>I have the following code:</p>
  <p>My models.py extract:</p>
  <pre><code>class Email(models.Model):
      user_email = models.CharField(primary_key=True, max_length=200)
      user_phone_number = models.IntegerField()
      user_device_id = models.CharField(max_length=200)#request.META.get('HTTP_DEVICE', '')
      lat = models.DecimalField(max_digits=22, decimal_places=16, blank=True, null=True)
      lng = models.DecimalField(max_digits=22, decimal_places=16, blank=True, null=True)
      user_address = models.CharField(max_length=200)
      creation_date = models.DateTimeField(default=None)
      email_status = models.BooleanField(default=False)
      email_score = models.IntegerField()
      valid_email = models.BooleanField(default=False)
      fraud = models.BooleanField(default=False)
  </code></pre>
  <p>My views.py extract:</p>
  <pre><code>class UserListView(APIView):
      serializer_class = EmailSerializer
      queryset = Email.objects.all()
      pagination_class = StandardResultsSetPagination
      
      def get_serializer_class(self):
          if self.action == 'list':
              return EmailListSerializer
          return EmailSerializer
      
      def post(self, request, *args, **kwargs):
          parametros = request.POST
          email='email=' + request._full_data['user_email']
          response = UserConnector(email).get_user_data()
          obgs = response[1]['results']
          if len(obgs) == 0:
              user_email = self.request.POST.get('user_email')
              email_stat = ''
              email_scor = ''
              email_valid = ''
              frau = ''
          else:
              obg = response[1]['results'][0]
  
              user_email = self.request.POST.get('user_email')
              email_stat = obg.get('email_status')
              email_scor = obg.get('email_score')
              email_valid = obg.get('valid_email')
              frau = obg.get('fraud')
  
          NewEmail = Email(
              user_email = user_email,
              user_phone_number = self.request.POST.get('user_phone_number'),
              user_device_id = request.META.get('HTTP_DEVICE', ''),
              lat = self.request.POST.get('lat'),
              lng = self.request.POST.get('lng'),
              user_address = self.request.POST.get('user_address'),
              creation_date = timezone.now,
              email_status = email_stat,
              email_score = email_scor,
              valid_email = email_valid,
              fraud = frau
          )
      NewEmail.save()
      serializer = EmailSerializer(NewEmail)
      return Response(serializer.data)
  </code></pre>
  <p>I have receive the folowing JSON response:</p>
  <pre><code>{
      &quot;user_email&quot;: &quot;meloadik@gmail.com&quot;,
      &quot;user_phone_number&quot;: 8117904544,
      &quot;user_device_id&quot;: &quot;&quot;,
      &quot;lat&quot;: &quot;20.9750000000000000&quot;,
      &quot;lng&quot;: &quot;89.6141400000000000&quot;,
      &quot;user_address&quot;: &quot;rfm mz5 lt4&quot;,
      &quot;creation_date&quot;: &quot;2022-08-23T22:47:13.687178Z&quot;,
      &quot;email_status&quot;: null,
      &quot;email_score&quot;: 0,
      &quot;valid_email&quot;: 0,
      &quot;fraud&quot;: 0
  }
  </code></pre>
  <p>I want to know how to format the JSON response differently, like this:</p>
  <pre><code>{
      &quot;email_response&quot;: {
      &quot;user_email&quot;: &quot;carl@trully.ai&quot;,
      &quot;creation_date&quot;: &quot;2020/06/01&quot;,
      &quot;email_status&quot;: &quot;active&quot;,
      &quot;email_score&quot;: 910,
      &quot;valid_email&quot;: 1,
      &quot;fraud&quot;: 0
      },
      &quot;phone_response&quot;: {
          &quot;user_phone_number&quot;: 8117904544,
      }
  
  }
  </code></pre>
  <p>Or modify my JSON Response with different types of styles, tabs, spaces, etc...</p>