search_form

Renders a form with a text input as a search form. The first argument must be the query flag that is used to send the search query with as URL parameter.

Also accepts the following arguments:

  • url: The URL to show the search results on (Optional, default: current url)

  • form_class: The html class for the search form tag. (Optional)

  • Every other key-value argument will be used as html tags for the input.

The following generates a GET request for the search page '/search'.

{% search_form "q", url: "/search" %}

When submitted, the search form makes a GET request to the following url: '/search?q=<search query>'.

HTML output:

<form action="/search" class=""> <input type="text" name="q" value=""> </form>