Yep. My solution is a custom template tag

from django.template.defaulttags import register
from urllib.parse import urlencode

@register.simple_tag(takes_context=True)
def querystringmod(context, *args):
    """Modify current querystring:
     {% querystringmod name value [name value [...]] %}
    """
    if (len(args) % 2) !=0:
        args.append("")
    request = context['request']
    current_qs = request.GET.dict()
    current_qs.update(dict([ (args[n], args[n+1]) for n in range(0, len(args
), 2) ]))
    return urlencode(current_qs)

in template
<a href="?{% querystringmod "page" page_obj.previous_page_number %}">
previous</a>



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31ec3240-cee2-41b5-acd0-f4e05d41fb61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to