Skip to content

Instantly share code, notes, and snippets.

View leonsmith's full-sized avatar
😬
.

Leon Smith leonsmith

😬
.
View GitHub Profile
@leonsmith
leonsmith / url_add_query.py
Created May 16, 2013 09:16
Django template tag to append a query string to a url
from urlparse import urlsplit, urlunsplit
from django import template
from django.http import QueryDict
register = template.Library()
@register.simple_tag
def url_add_query(url, **kwargs):
"""
@leonsmith
leonsmith / pagination_range.py
Last active July 6, 2020 17:22
Pagination range, used to limit huge pagination objects
from django import template
register = template.Library()
@register.filter
def pagination_range(obj, current=1, limit=10):
"""
Used with pagination page_range object when you have a lot of pages