  
      def _get_num_pages(self):
          "Returns the total number of pages."
          if self._num_pages is None:
              hits = self.count - 1 - self.orphans
              if hits < 1:
                  hits = 0
              if hits == 0 and not self.allow_empty_first_page:
                  self._num_pages = 0
              else:
                  self._num_pages = hits // self.per_page + 1
          return self._num_pages
      num_pages = property(_get_num_pages)
 
</s> remove                 self._num_pages = hits // self.per_page + 1
 </s> add                 hits = max(1, self.count - self.orphans)
                self._num_pages = int(ceil(hits / float(self.per_page)))
            if self.count == 0 and not self.allow_empty_first_page:
  
      def _get_num_pages(self):
          "Returns the total number of pages."
          if self._num_pages is None:
            if self.count == 0 and not self.allow_empty_first_page:
            if self.count == 0 and not self.allow_empty_first_page:
            if self.count == 0 and not self.allow_empty_first_page:
            if self.count == 0 and not self.allow_empty_first_page:
                  self._num_pages = 0
              else:
                  self._num_pages = hits // self.per_page + 1
          return self._num_pages
      num_pages = property(_get_num_pages)
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Fixed #6997 -- Corrected `num_pages` calculation when one item is in the object list and `allow_empty_first_page=False`, thanks to framos for the report.  Also, made Page's `start_index()` return 0 if there are no items in the object list (previously it was returning 1, but now it is consistent with `end_index()`).  As an added bonus, I threw in quite a few pagination tests.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8129 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/core/paginator.py