Last active
September 1, 2025 00:54
-
-
Save benbacardi/d6cd0fb8c85e1547c3c60f95f5b2d5e1 to your computer and use it in GitHub Desktop.
Revisions
-
benbacardi revised this gist
Jun 29, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,6 @@ def query_transform(context, **kwargs): A RequestContext is required for access to the current querystring. ''' query = context['request'].GET.copy() for k, v in kwargs.items(): query[k] = v return query.urlencode() -
benbacardi revised this gist
Sep 7, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ def query_transform(context, **kwargs): updating the params with the key/value pairs passed to the tag. E.g: given the querystring ?foo=1&bar=2 {% query_transform bar=3 %} outputs ?foo=1&bar=3 {% query_transform foo='baz' %} outputs ?foo=baz&bar=2 {% query_transform foo='one' bar='two' baz=99 %} outputs ?foo=one&bar=two&baz=99 -
benbacardi revised this gist
Aug 24, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ def query_transform(context, **kwargs): E.g: given the querystring ?foo=1&bar=2 {% query_transform bar=3 %} outputs ?foo=1&bar=4 {% query_transform foo='baz' %} outputs ?foo=baz&bar=2 {% query_transform foo='one' bar='two' baz=99 %} outputs ?foo=one&bar=two&baz=99 A RequestContext is required for access to the current querystring. ''' -
benbacardi created this gist
Aug 24, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ from django import template register = template.Library() @register.simple_tag(takes_context=True) def query_transform(context, **kwargs): ''' Returns the URL-encoded querystring for the current page, updating the params with the key/value pairs passed to the tag. E.g: given the querystring ?foo=1&bar=2 {% query_transform bar=3 %} outputs ?foo=1&bar=4 {% query_transform foo='baz' %} outputs ?foo=baz&bar=2 A RequestContext is required for access to the current querystring. ''' query = context['request'].GET.copy() for k, v in kwargs.iteritems(): query[k] = v return query.urlencode()