title: Handling a success and failure response Django
body: <p>user is sending an api request to crate order along with  information in request body and after saving the data i am returning the order_id and access_token to the user.I have used few authentications also with using model.full_clean().Now i am stuck on the part to return success and failure status code and message along with the order_id and access_token.</p>
  <pre><code>@api_view(['POST'])
  def orderdetails(request):  
      try:
          ACCESS_KEY_ID = request.META.get('HTTP_ACCESS_KEY_ID')
          ACCESS_KEY_SECRET = request.META.get('HTTP_ACCESS_KEY_SECRET')
          applications = Applications.objects.all()
          id=0
          for e in applications:
              if(e.ACCESS_KEY_ID==ACCESS_KEY_ID and e.ACCESS_KEY_SECRET==ACCESS_KEY_SECRET ):
                  id = e.id+id
                  print(id)
                  break
          else:
              return Response({&quot;Message&quot;:&quot;Enter Valid Credentials&quot;})
      except ValueError:
          return Response({&quot;ACCESS&quot;:&quot;DENIED&quot;})
              
              
      if request.method == 'POST':       
          data=request.data
          print(data)
          orders = Orders(applications=Applications.objects.get(id=id),
          purpose_code = data['purpose_code'],
          amount=data['amount'],
          currency=data['currency'],
          note=data['note'],
          payer_name=data['payer_name'],
          payer_email=data['payer_email'],
          payer_phone_country_code=data['payer_phone_country_code'],
          payer_phone_number=data['payer_phone_number'],
          payee_name=data['payee_name'],
          payee_email=data['payee_email'],
          payee_phone_country_code=data['payee_phone_country_code'],
          payee_phone_number=data['payee_phone_number'],
          payee_pan = data['payee_pan'],
          payee_bank_account_holder_name=data['payee_bank_account_holder_name'],
          payee_bank_account_number=data['payee_bank_account_number'],
          payee_bank_account_ifsc=data['payee_bank_account_ifsc'],
          payee_bank_account_type=data['payee_bank_account_type'],
          payee_bank_account_beneficiary_identifier=data['payee_bank_account_beneficiary_identifier'],
          payment_collection_webhook_url=data['payment_collection_webhook_url'],
          payment_transfer_webhook_url=data['payment_transfer_webhook_url'],
          payment_gateway_code = data['payment_gateway_code'],
          isActive=data['isActive']
          )
          try:
              orders.full_clean()
          except ValidationError:
              return Response({&quot;Error message&quot;:&quot;invalid request body&quot;})
                                 
          else:
              orders.save()
              serializer = OrderSerializer(orders)
              order_id = serializer.data['id']
              access_token = serializer.data['access_token']
              return Response({&quot;orderId&quot;:order_id,&quot;accessToken&quot;:access_token})
  </code></pre>
  <p>required Success and failure response in the format bellow :
  Success response (201/202) along with order_id and access_token
  Failure response (422) along with message: &quot;error message content&quot;</p>