Search within results using haystack (django) on solr
I'm trying to search within a previous search on my site.
It would be like "sky", and then after getting the results, I'd hit the radio button for 'Search within results'. Then I would type in "blue" (assuming the search bar is now empty). Thus, I would search on "sky blue".
I've been looking around quite a bit for solutions to this, but nothing seems to have been posted in this explicivity.
I'm passing the form to a custom form, but I've been unable to ac开发者_运维百科cess the radio box. I would LIKE to just save the original query, and then if I've selected to search within, I would just make an append.
Any ideas?
Thanks.
Do you mean using a checkbox? Assuming you are clearing your search field after a form request. I'm not sure how much of the django form you are using but at a basic level, after an initial search, you can push the value from the view to the template in its own variable:
initial_keyword = 'sky' # default to empty if none entered
In the template, insert the following within your html form tags:
<input type="hidden" name="initial_keyword" value="{{ initial_keyword }}" />
Check the values of request.GET
, you should see initial_keyword
and maybe your checkbox. From there, if checkbox is checked, combine initial_keyword
and the newly entered value.
精彩评论