mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 19:36:26 -06:00
Documentation update
This commit is contained in:
parent
32b05080d5
commit
41deeb4dc9
@ -60,6 +60,10 @@ class MyModelViewSet(...):
|
|||||||
### TagFilter
|
### TagFilter
|
||||||
|
|
||||||
The `TagFilter` class is available for all models which support tag assignment (those which inherit from `NetBoxModel` or `TagsMixin`). This filter subclasses django-filter's `ModelMultipleChoiceFilter` to work with NetBox's `TaggedItem` class.
|
The `TagFilter` class is available for all models which support tag assignment (those which inherit from `NetBoxModel` or `TagsMixin`). This filter subclasses django-filter's `ModelMultipleChoiceFilter` to work with NetBox's `TaggedItem` class.
|
||||||
|
This class filters `tags` using the `slug` field. For example:
|
||||||
|
|
||||||
|
`GET /api/dcim/sites/?tag=alpha&tag_id=bravo`
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from django_filters import FilterSet
|
from django_filters import FilterSet
|
||||||
@ -68,3 +72,18 @@ from extras.filters import TagFilter
|
|||||||
class MyModelFilterSet(FilterSet):
|
class MyModelFilterSet(FilterSet):
|
||||||
tag = TagFilter()
|
tag = TagFilter()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### TagIDFilter
|
||||||
|
|
||||||
|
The `TagIDFilter` class is available for all models which support tag assignment (those which inherit from `NetBoxModel` or `TagsMixin`). This filter subclasses django-filter's `ModelMultipleChoiceFilter` to work with NetBox's `TaggedItem` class.
|
||||||
|
This class filters `tags` using the `id` field. For example:
|
||||||
|
|
||||||
|
`GET /api/dcim/sites/?tag_id=100&tag_id=200`
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django_filters import FilterSet
|
||||||
|
from extras.filters import TagIDFilter
|
||||||
|
|
||||||
|
class MyModelFilterSet(FilterSet):
|
||||||
|
tag_id = TagIDFilter()
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user