Reputation: 1
I have a table in django template.
My current url is /tmp/example/
Ans No. of Yes No. of No. No of Noides.
50 10 20 21
Men 3 10 10
Female 7 10 11
So basically I am displaying the number by doing filter and using count() in the end. SO my problem is how can I make the numbers as link and pass it to other url .
so say I click No of no. (20) it takes me to '/tmp/' which gives me one more table of all the 20 list values.
I can pass the list of object id or something from the first url.
so say i have view
def someview(request):
# ger all objects and find out the count
# retun_to_response()
in url '/tmp/example/' is link to someview
and I want to define '/tmp/' which i got after clicking on the numberlink in the /tmp/example/ table.
so i can i do that.
Upvotes: 0
Views: 249
Reputation: 92587
You need to have another url pattern defined first to take you to the page you want for that result. And you also need to make sure you name that pattern: https://docs.djangoproject.com/en/1.3/topics/http/urls/#id2
Then in your template, you can create a link around each result that resolves to a url: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url
That url
template tag will reverse the url pattern name, and the args you give it to produce the proper url.
Upvotes: 1