2 >>> from django.core.paginator import Paginator
3 >>> from pagination.templatetags.pagination_tags import paginate
4 >>> from django.template import Template, Context
6 >>> p = Paginator(range(15), 2)
7 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
8 [1, 2, 3, 4, 5, 6, 7, 8]
10 >>> p = Paginator(range(17), 2)
11 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
12 [1, 2, 3, 4, 5, 6, 7, 8, 9]
14 >>> p = Paginator(range(19), 2)
15 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
16 [1, 2, 3, 4, None, 7, 8, 9, 10]
18 >>> p = Paginator(range(21), 2)
19 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
20 [1, 2, 3, 4, None, 8, 9, 10, 11]
23 >>> p = Paginator(range(5), 2, 1)
24 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
27 >>> p = Paginator(range(21), 2, 1)
28 >>> paginate({'paginator': p, 'page_obj': p.page(1)})['pages']
29 [1, 2, 3, 4, None, 7, 8, 9, 10]
31 >>> t = Template("{% load pagination_tags %}{% autopaginate var 2 %}{% paginate %}")
33 # WARNING: Please, please nobody read this portion of the code!
34 >>> class GetProxy(object):
35 ... def __iter__(self): yield self.__dict__.__iter__
36 ... def copy(self): return self
37 ... def urlencode(self): return u''
38 ... def keys(self): return []
39 >>> class RequestProxy(object):
45 >>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
46 u'\\n\\n<div class="pagination">...
48 >>> t = Template("{% load pagination_tags %}{% autopaginate var %}{% paginate %}")
49 >>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
50 u'\\n\\n<div class="pagination">...
51 >>> t = Template("{% load pagination_tags %}{% autopaginate var 20 %}{% paginate %}")
52 >>> t.render(Context({'var': range(21), 'request': RequestProxy()}))
53 u'\\n\\n<div class="pagination">...
54 >>> t = Template("{% load pagination_tags %}{% autopaginate var by %}{% paginate %}")
55 >>> t.render(Context({'var': range(21), 'by': 20, 'request': RequestProxy()}))
56 u'\\n\\n<div class="pagination">...