I’m creating a site like craigslist and need to implement a search feature where customers can search for a key term and see results. For example, searching for “lamp” will create a result page with all the posts that are related to lamps.
I’m using Haystack / Solr to search the contents. However, at the moment, users have to go to a specific search page where they can then narrow their results.
How do I implement it in such a way that the search bar can appear in my header on every page? I’m using Django.
It’s a good idea to have all pages extend a base template. So you can have one template (e.g.
base.html) that contains the basic structure of your site (headers, footers, boilerplate). Then you can extend this template for each page of your site. (i.e.{% extends 'base.html' %}).Following this structure, you should be able to put your search form in the base template and have it appear on all pages.