title: Place Primary key inside JSON response
body: <p>The JSON response i'm getting is as below.</p>
  
  <p><a href="https://i.stack.imgur.com/XFUjD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFUjD.png" alt="enter image description here"></a></p>
  
  <p>In my code i'am trying to fetch the list from the db, as per above img. In the result <code>primary key</code> is coming outside of the fields for each record. How can i place it inside the fields for every record like.</p>
  
  <pre><code>"results":[
    "fields":{
        "pk": "F09087687633",
        "company_name": "Tata",
    }
  ]
  </code></pre>
  
  <p>Below is my code:</p>
  
  <p><strong>views.py</strong> (In below code for loop is to remove app name from the results, same i use to remove primary key, it is working but how can i place it inside for each fields.)</p>
  
  <pre><code>@csrf_exempt
  def fleet_owner_list(request):
   page_number = json.loads(request.body)
   records,total_pages = FleetOwner.get_all_owners(page_number)
   for data in range(len(records)):
     del records[data]['model']
   returnObject = {
         "page" : page_number,
         "total_results":len(records),
         "total_pages":total_pages,
         "status" : messages.RETRIVAL_SUCCESS,
         "message" : messages.FLEETOWNER_DATA_RETRIEVE_SUCCESS,
         "results" : records
     }
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>@classmethod
     def get_all_owners(cls,page_number):
        data = cls.objects.filter(is_deleted = False)
        page_numbers = page_number
        pegination_result, total_page_count = list_paginate(data, page_numbers)
        data = serializers.serialize("json", pegination_result)
        data = json.loads(data)
        return data, total_page_count
  </code></pre>
  
  <p><strong>paginator.py</strong> (This is a common function i'm using for all the list functions to perform django pagination.)</p>
  
  <pre><code>def list_paginate(data,page_numbers):
       paginator = Paginator(data,10)
       page = page_numbers
       try :
             records = paginator.page(page)
       except PageNotAnInteger:
             records = paginator.page(1)
       except EmptyPage:
             records = paginator.page(paginator.num_pages)
       return records, paginator.num_pages
            pegination_result, total_page_count = list_paginate(data, page_numbers)
            data = serializers.serialize("json", pegination_result)
            data = json.loads(data)
            return data, total_page_count
  </code></pre>