How do i pass GET parameters using django urlresolvers reverse

yossi picture yossi · Mar 6, 2012 · Viewed 38.2k times · Source

I am using django 1.2 and going from one view to another using the urlresolvers reverse method.

url = reverse(viewOne)

and I want to pass a get parameter, for example

name = 'joe'

so that in the viewOne if I do

def viewOne(request):
    request.GET['name']

I will get

joe

how do I do that ?

Answer

Daniel Roseman picture Daniel Roseman · Mar 6, 2012

GET parameters have nothing to do with the URL as returned by reverse. Just add it on at the end:

url = "%s?name=joe" % reverse(viewOne)