combo/combo/apps/search
Valentin Deniaud 66b12b846a misc: change django-upgrade target version to 3.2 (#75442) 2023-03-29 16:14:41 +02:00
..
migrations misc: change django-upgrade target version to 3.2 (#75442) 2023-03-29 16:14:41 +02:00
templates/combo search: add missing space before custom title in cell configuration (#72637) 2022-12-23 08:58:18 +01:00
README search: add possibility to specify templates for hits (#25614) 2018-08-31 16:01:16 +02:00
__init__.py misc: change django-upgrade target version to 3.2 (#75442) 2023-03-29 16:14:41 +02:00
engines.py misc: apply pyupgrade (#55868) 2021-07-27 16:45:52 +02:00
forms.py search: configure target page for card engine (#68606) 2022-09-12 14:48:42 +02:00
manager_views.py search: configure target page for card engine (#68606) 2022-09-12 14:48:42 +02:00
models.py misc: change django-upgrade target version to 3.2 (#75442) 2023-03-29 16:14:41 +02:00
urls.py misc: only allow numbers as search cell id in URLs (#72721) 2022-12-28 14:24:21 +01:00
utils.py search: index external links data independently (#58269) 2021-11-04 18:09:33 +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}}',
      },
  }