combo/combo/apps/search
Frédéric Péters aea9d7db5d search: simplify generated javascript (#18921) 2019-04-15 09:58:19 +02:00
..
management misc: remove external links from search index when --remove is given (#28160) 2018-11-20 09:18:28 +01:00
migrations search: handle several search engines (#23534) 2018-08-30 11:50:06 +02:00
templates/combo search: simplify generated javascript (#18921) 2019-04-15 09:58:19 +02:00
README search: add possibility to specify templates for hits (#25614) 2018-08-31 16:01:16 +02:00
__init__.py search: add a singleton so apps can register their search engines (#25620) 2018-08-30 11:50:06 +02:00
engines.py search: change registration to take a function (#26260) 2019-01-02 08:58:11 +01:00
forms.py search: add custom widget to sort and enable engines (#23534) 2018-08-30 11:50:06 +02:00
models.py search: don't display "no result found" when there is no query (#32038) 2019-04-09 18:28:20 +02:00
urls.py wcs: register search engines for formdata of wcs sites (#26260) 2019-01-02 08:58:11 +01:00

README

Configure search services in settings.COMBO_SEARCH_SERVICES:

  COMBO_SEARCH_SERVICES = {
      'user': {
          'label': 'Search a user',
          'url': 'https://.../api/user/?q=%(q)s',
          # 'cache_duration': 60,  # in seconds, default is 0
          # 'signature': True,     # boolean, default is False
      },
  }

'url' must return a JSON:

  {
    "err": 0,
    "data": [
      {
        'url': 'https://example.net/page3/',
        'text': 'example, page3',
        'description': 'this can be <b>html</b> text'
      },
      { ... }, ...
    ]
    ...
  }

which is sent to template 'combo/search-cell-results.html'

If the cell slug is "foo" and a variable named "foo" exists in the
query_string, it is added to the global page context, so it can be
used, for example, by a JsonCell.


It is also possible to extend the search service definition with custom
templates for hit URLs and labels:

  COMBO_SEARCH_SERVICES = {
      'user': {
          'label': 'Search a user',
          'url': 'https://.../api/user/?q=%(q)s',
          'hit_url_template': '/fiche-usager/{{user_name_identifier_0}}/',
          'hit_label_template': '{{first_name}} {{last_name}}',
      },
  }