          Returns the 1-based index of the last object on this page,
          relative to total objects found (hits).
          """
          if self.number == self.paginator.num_pages:
              return self.paginator.count
          return self.number * self.paginator.per_page
  
 
</s> remove             hits = self.count - 1 - self.orphans
            if hits < 1:
                hits = 0
            if hits == 0 and not self.allow_empty_first_page:
 </s> add             if self.count == 0 and not self.allow_empty_first_page: </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)))
        # Special case for the last page because there can be orphans.
          Returns the 1-based index of the last object on this page,
          relative to total objects found (hits).
          """
        # Special case for the last page because there can be orphans.
          if self.number == self.paginator.num_pages:
              return self.paginator.count
          return self.number * self.paginator.per_page
  
keep keep add 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