From bf3cf6f217a5d965cd2af11d43deff037cf11cc9 Mon Sep 17 00:00:00 2001 From: shagi Date: Tue, 2 Mar 2021 16:16:55 +0100 Subject: [PATCH] New templatetag for pagination --- gas/templates/gas/tags/pagination.html | 28 ++++++++++++++++++++++++++ gas/templatetags/gas_tags.py | 23 ++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 gas/templates/gas/tags/pagination.html diff --git a/gas/templates/gas/tags/pagination.html b/gas/templates/gas/tags/pagination.html new file mode 100644 index 0000000..e335fce --- /dev/null +++ b/gas/templates/gas/tags/pagination.html @@ -0,0 +1,28 @@ +{% load i18n %} +{% load custom_gas_tags %} + +{% if page %} + +{% endif %} diff --git a/gas/templatetags/gas_tags.py b/gas/templatetags/gas_tags.py index 4d95a80..b69527e 100644 --- a/gas/templatetags/gas_tags.py +++ b/gas/templatetags/gas_tags.py @@ -1,5 +1,6 @@ -# -*- coding: utf-8 -*- import datetime +import json +from urllib.parse import urlencode from django import template from django.utils.html import mark_safe @@ -39,3 +40,23 @@ def display_boolean(value): else: render = '' return mark_safe(render) + + +@register.simple_tag +def url_replace(request, **kwargs): + query = request.GET.dict() + query.update(kwargs) + return urlencode(query) + + +@register.inclusion_tag("gas/tags/pagination.html") +def pagination(request, page): + return { + 'request': request, + 'page': page, + } + + +@register.filter +def to_json(data): + return mark_safe(json.dumps(data))