I\'m trying to reverse a named URL and include a querystring in it. Basically, I\'ve modified the login function, and I want to send ?next=
in it.
Here\'s w
I just made my own utility function like the one asked in the question:
from django.utils.http import urlencode
def my_reverse(viewname, kwargs=None, query_kwargs=None):
"""
Custom reverse to add a query string after the url
Example usage:
url = my_reverse('my_test_url', kwargs={'pk': object.id}, query_kwargs={'next': reverse('home')})
"""
url = reverse(viewname, kwargs=kwargs)
if query_kwargs:
return u'%s?%s' % (url, urlencode(query_kwargs))
return url