Add to examples in docs

This commit is contained in:
Jeremy Stretch 2023-11-02 14:05:54 -04:00
parent 7bcc69c043
commit 326c954782
2 changed files with 4 additions and 0 deletions

View File

@ -17,6 +17,7 @@ class MyModelIndex(SearchIndex):
('description', 500), ('description', 500),
('comments', 5000), ('comments', 5000),
) )
display_attrs = ('site', 'device', 'status', 'description')
``` ```
A SearchIndex subclass defines both its model and a list of two-tuples specifying which model fields to be indexed and the weight (precedence) associated with each. Guidance on weight assignment for fields is provided below. A SearchIndex subclass defines both its model and a list of two-tuples specifying which model fields to be indexed and the weight (precedence) associated with each. Guidance on weight assignment for fields is provided below.

View File

@ -14,8 +14,11 @@ class MyModelIndex(SearchIndex):
('description', 500), ('description', 500),
('comments', 5000), ('comments', 5000),
) )
display_attrs = ('site', 'device', 'status', 'description')
``` ```
Fields listed in `display_attrs` will not be cached for search, but will be displayed alongside the object when it appears in global search results. This is helpful for conveying to the user additional information about an object.
To register one or more indexes with NetBox, define a list named `indexes` at the end of this file: To register one or more indexes with NetBox, define a list named `indexes` at the end of this file:
```python ```python