mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-18 11:22:25 -06:00
This commit is contained in:
committed by
GitHub
parent
9ebaa1d1d0
commit
c7fa168747
@@ -61,6 +61,11 @@ class MyModelViewSet(...):
|
||||
|
||||
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=bravo`
|
||||
|
||||
|
||||
```python
|
||||
from django_filters import FilterSet
|
||||
from extras.filters import TagFilter
|
||||
@@ -68,3 +73,19 @@ from extras.filters import TagFilter
|
||||
class MyModelFilterSet(FilterSet):
|
||||
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()
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user