@register.simple_tag(takes_context=True)
def querystring(context, **kwargs):
 request = context[u'request']
 querydict = request.GET.copy()
 for (key, value) in kwargs.items():
  if (value is None):
   querydict.pop(key, None)
  else:
   querydict[key] = value
 return (u'?' + querydict.urlencode())

@ register . simple_tag ( takes_context = True ) def querystring ( context , ** kwargs ) : request = context [ u'request' ] querydict = request . GET . copy ( ) for ( key , value ) in kwargs . items ( ) : if ( value is None ) : querydict . pop ( key , None ) else : querydict [ key ] = value return ( u'?' + querydict . urlencode ( ) )
creates a url derived from the current urls querystring .