diff --git a/core/templates/pagination.html b/core/templates/pagination.html new file mode 100644 index 0000000..c10eee0 --- /dev/null +++ b/core/templates/pagination.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/core/templatetags/__init__.py b/core/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/core/templatetags/__init__.py diff --git a/core/templatetags/pagination.py b/core/templatetags/pagination.py new file mode 100644 index 0000000..b55fd91 --- /dev/null +++ b/core/templatetags/pagination.py @@ -0,0 +1,22 @@ +from django import template + +register = template.Library() + + +@register.inclusion_tag('pagination.html') +def pagination(request, paginator, page_obj): + context = { + 'request': request, + 'paginator': paginator, + 'page_obj': page_obj, + } + + getvars = request.GET.copy() + + if 'page' in getvars: + del getvars['page'] + + if len(getvars) > 0: + context['getvars'] = '&%s' % getvars.urlencode() + + return context \ No newline at end of file diff --git a/users/templates/list_users.html b/users/templates/list_users.html index 21ba545..486fd9f 100644 --- a/users/templates/list_users.html +++ b/users/templates/list_users.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% load i18n %} +{% load i18n pagination %} {% block breadcrumbs %}
@@ -50,5 +50,8 @@
{% endfor %} + {% pagination request paginator page_obj %} + {% else %} + {% endif %} {% endblock %} -- libgit2 0.21.2