summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2006-11-07 04:44:27 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2006-11-07 04:44:27 +0000
commitd4d1a22730eecd207d0e656161d24a52284112bf (patch)
tree7569f54babc732db3c72848e4402c7511b99d654 /tests
parentdabf0366044e053e5577c096b19d1d7d2bebfe9a (diff)
Fixed #2575: ObjectPaginator now accepts a "orphans" option to prevent pages with only a few items. Thanks, SmileyChris.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4041 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/pagination/models.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/modeltests/pagination/models.py b/tests/modeltests/pagination/models.py
index ea2385dc79..3319b5cafa 100644
--- a/tests/modeltests/pagination/models.py
+++ b/tests/modeltests/pagination/models.py
@@ -64,4 +64,17 @@ True
>>> paginator.last_on_page(1)
9
+# Add a few more records to test out the orphans feature.
+>>> for x in range(10, 13):
+... Article(headline="Article %s" % x, pub_date=datetime(2006, 10, 6)).save()
+
+# With orphans set to 3 and 10 items per page, we should get all 12 items on a single page:
+>>> paginator = ObjectPaginator(Article.objects.all(), 10, orphans=3)
+>>> paginator.pages
+1
+
+# With orphans only set to 1, we should get two pages:
+>>> paginator = ObjectPaginator(Article.objects.all(), 10, orphans=1)
+>>> paginator.pages
+2
"""}