title: Any way to serialize a pagination object in Django?
body: <p>I'm using Django pagination with jQuery. I can serialize the objects list of the pagination object, but I'd like to serialize the whole object to get more data (page number, total number of pages...).
  How can I serialize the whole pagination object?</p>
  
  <p>Thanks</p>
  
  <p>javascript</p>
  
  <pre><code>function getRestaurants(query) {
  
          $.post("/getRestaurant/", query,
              function(data) {
                  /* do stuff with data */
               },"json" );
  }
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def getRestaurant(request):
  
      results = Restaurant.objects.all()
      paginator = Paginator(restaurants, 5)
  
      # Make sure page request is an int. If not, deliver first page.
      try:
          page = int(request.POST.get('page','1'))
      except ValueError:
          page = 1
  
      # If page request (9999) is out of range, deliver last page of results.
      try:
          results = paginator.page(page)
      except (EmptyPage, InvalidPage):
          results = paginator.page(paginator.num_pages)
  
      data=serializers.serialize("json", results.object_list) #I'd like to serialize the whole results object
  
      return HttpResponse(data)
  </code></pre>