You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want your plugin models to appear in search results, you will need to create a search index for the models. Search indexes must be in defined in a search_indexes.py file.
4
+
5
+
As an example, lets define a search_index for the MyModel object defined before:
6
+
7
+
```python
8
+
# search_indexes.py
9
+
from .filters import MyFilterSet
10
+
from .tables import MyModelTable
11
+
from .models import MyModel
12
+
from search.models import SearchMixin
13
+
14
+
15
+
classMyModelIndex(SearchMixin):
16
+
model = MyModel
17
+
queryset = MyModel.objects.all()
18
+
filterset = MyModelFilterSet
19
+
table = MyModelTable
20
+
url ='plugins:netbox_mymodel:mymodel_list'
21
+
choice_header ='MyModel'
22
+
```
23
+
24
+
All the fields must be defined as follows:
25
+
26
+
*`model` - The model that will be searched (see: [Models](./models.md)).
27
+
*`queryset` - The queryset on the model that will be passed to the filterset.
28
+
*`filterset` - The filterset for the model that contains the search method (see: [Filters & Filter Sets](./filtersets.md)).
29
+
*`table` - Table that is used in the list view (see: (see: [Tables](./tables.md)).
30
+
*`url` - URL to the list view to show search results.
31
+
*`choice_header` - The header that will appear in the search drop-down to group menu items together.
0 commit comments