In django , how to make a link out of a search value returned?
This is the inital question and I had asked , as there were 2 questions in it , I thought I will make another question from it .
How to make this django attribute name search better? .
The second question there was , once a search value is returned to searchresult.html . How do I make link out of it , that would link directly to the search data .
if the result returned is "Park" , which is a name of the file , How do I make it link , which I can link to another view that shows the contents of the开发者_C百科 data ?
I read your first question. I will give you an idea.
In your search results template, you have a dictionary named data. With that, you can get the ID of the object in the search results. Create a hyperlink with that ID. ex:
<a href='/view-details/{{ data.id }}'>{{ data }}</a>
Make a function in your views that gets the detail of an Object using it's ID. (It's parameter should require an ID.)
Create a template for that view.
Map the function and the url in the urls.py of your app. For example:
url(r'^view-details/(?P)/$', 'view_details', name='details'),
精彩评论