'Returns the total number of pages.'

def _get_num_pages(self):

    if (self._num_pages is None):
        if ((self.count == 0) and (not self.allow_empty_first_page)):
            self._num_pages = 0
        else:
            hits = max(1, (self.count - self.orphans))
            self._num_pages = int(ceil((hits / float(self.per_page))))
    return self._num_pages
