1 from django.template import Library
6 @register.inclusion_tag('prevnext/previous.html', takes_context=True)
7 def previous_page(context, fallback=None, fallback_title=None):
8 current = context['page_obj'].number
10 return {'number': current - 1, 'title': None, 'url': None}
12 return {'number': None, 'title': fallback_title, 'url': fallback}
15 @register.inclusion_tag('prevnext/next.html', takes_context=True)
16 def next_page(context, fallback=None, fallback_title=None):
17 current = context['page_obj'].number
18 page_range = context['paginator'].page_range
19 if current < page_range[-1]:
20 return {'number': current + 1, 'title': None, 'url': None}
22 return {'number': None, 'title': fallback_title, 'url': fallback}
25 @register.inclusion_tag('prevnext/prevnext.html', takes_context=True)
26 def prevnext(context):