This module contains utilities for searching.
Takes a search string and parses it into a list of keywords and phrases.
Generate a dictionary of pages to show around the current page. Show 3 numbers on either side of the specified page, or more if close to end or beginning of available pages.
Parameters: |
|
---|---|
Return type: | dictionary; keys are page numbers, values are page labels |
Parse a string of search terms into keywords, phrases, and field/value pairs. Use quotes (” “) to designate phrases and field:value or field:”term term” to designated field value pairs. Returns a list of tuples where the first value is the field, or None for a word or phrase, second value is the keyword or phrase. Incomplete field value pairs will return a tuple with None for the value. For example:
parse_search_terms('grahame "frog and toad" title:willows')
Would result in:
[(None,'grahame'), (None, 'frog and toad'), ('title', 'willows')]
Django template tag to display pagination links for a paginated list of items.
Example use:
{% load search_utils %}
{% pagination_links paged_items show_pages %}