-
Notifications
You must be signed in to change notification settings - Fork 128
Template tags
django-watson comes with a template tag library called watson
. You can include this template tag library in your templates with the following code:
{% load watson %}
This library contains the following template tags and filters:
Renders a list of search results in a page. If the project is using Django 1.4 or above, the object
of each search entry will be prefetched using prefetch_related
. The results will be rendered using the "watson/includes/search_results.html"
template.
{% search_results search_entry_list %}
-
search_entry_list - A
QuerySet
ofSearchEntry
. - query - The query string passed to the search view.
Renders a single search result. The results will be rendered using a template whose name corresponds to the type of the object referenced by the search entry. The template will be chosen according the to following naming scheme:
(
"watson/includes/search_result_{app_label}_{model_name}.html",
"watson/includes/search_result_{app_label}.html",
"watson/includes/search_result_item.html",
)
The template tag is useful for rendering different formatting depending on the type of the search entry.
{% search_result_item search_entry %}
-
result - The
SearchEntry
instance. - obj - The model instance referenced by the search entry.
- query - The query string passed to the search view.