-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #8470: Expose NetBoxTable in the plugins framework
- Loading branch information
1 parent
59d3f5c
commit 3c1ea5d
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Tables | ||
|
||
NetBox employs the [`django-tables2`](https://django-tables2.readthedocs.io/) library for rendering dynamic object tables. These tables display lists of objects, and can be sorted and filtered by various parameters. | ||
|
||
## NetBoxTable | ||
|
||
To provide additional functionality beyond what is supported by the stock `Table` class in `django-tables2`, NetBox provides the `NetBoxTable` class. This custom table class includes support for: | ||
|
||
* User-configurable column display and ordering | ||
* Custom field & custom link columns | ||
* Automatic prefetching of related objects | ||
|
||
It also includes several default columns: | ||
|
||
* `pk` - A checkbox for selecting the object associated with each table row | ||
* `id` - The object's numeric database ID, as a hyperlink to the object's view | ||
* `actions` - A dropdown menu presenting object-specific actions available to the user. | ||
|
||
### Example | ||
|
||
```python | ||
# tables.py | ||
import django_tables2 as tables | ||
from netbox.tables import NetBoxTable | ||
from .models import MyModel | ||
|
||
class MyModelTable(NetBoxTable): | ||
name = tables.Column( | ||
linkify=True | ||
) | ||
... | ||
|
||
class Meta(NetBoxTable.Meta): | ||
model = MyModel | ||
fields = ('pk', 'id', 'name', ...) | ||
default_columns = ('pk', 'name', ...) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters