26 lines
921 B
ReStructuredText
26 lines
921 B
ReStructuredText
|
|
||
|
Autocomplete
|
||
|
============
|
||
|
|
||
|
Even though autocomplete is generally most useful in a web app, e.g.
|
||
|
for customer lookup, here it is implemented in the data layer and has
|
||
|
no "web" parts to it per se. (Which means you could add autocomplete
|
||
|
to your console app?)
|
||
|
|
||
|
An "autocompleter" in Rattail is really just an object with one
|
||
|
important method,
|
||
|
:meth:`~rattail:rattail.autocomplete.base.Autocompleter.autocomplete()`.
|
||
|
|
||
|
Rattail comes with several autocompleters built-in. You can get a new
|
||
|
autocompleter easily enough from the app handler, and using it is just
|
||
|
as easy::
|
||
|
|
||
|
products_ac = app.get_autocompleter('products')
|
||
|
results = products_ac.autocomplete('root beer')
|
||
|
|
||
|
The results will be a list of dicts, each will have at least ``value``
|
||
|
(uuid) and ``label`` (name/description) items.
|
||
|
|
||
|
See also :class:`~rattail:rattail.autocomplete.base.Autocompleter` and
|
||
|
:meth:`~rattail:rattail.app.AppHandler.get_autocompleter()`.
|