code: def get_page_number_from_request(
          request, querystring_key=PAGE_LABEL, default=1):
      
      try:
          if request.method == 'POST':
              page_number = request.POST[querystring_key]
          else:
              page_number = request.GET[querystring_key]
  
          return int(page_number)
      except (KeyError, TypeError, ValueError):
          return default
docs: Retrieve the current page number from *GET* or *POST* data.
  
      If the page does not exists in *request*, or is not a number,
      then *default* number is returned.