diff --git a/drakul/base/templates/bootstrap_paginator.html b/drakul/base/templates/bootstrap_paginator.html new file mode 100644 index 0000000..0158998 --- /dev/null +++ b/drakul/base/templates/bootstrap_paginator.html @@ -0,0 +1,49 @@ +{% load base_extras %} + + +{% if is_paginated %} + +{% endif %} diff --git a/drakul/base/templatetags/base_extras.py b/drakul/base/templatetags/base_extras.py index d0b1dd3..d6276a1 100644 --- a/drakul/base/templatetags/base_extras.py +++ b/drakul/base/templatetags/base_extras.py @@ -8,3 +8,11 @@ def active(context, url_name): if context["request"].resolver_match.url_name == url_name: return "active" return "" + + +@register.simple_tag() +def paginator_pages(page_range: range, current_number: int, margin=5): + return range( + max(page_range.start, current_number - margin), + min(page_range.stop, current_number + margin + 1) + )