Skip to content

nautobot.apps.tables

Utilities for apps to implement data tables.

nautobot.apps.tables.BaseTable

Bases: Table

Default table for object lists

:param user: Personalize table display for the given user (optional). Has no effect if AnonymousUser is passed.

nautobot.apps.tables.BooleanColumn

Bases: Column

Custom implementation of BooleanColumn to render a nicely-formatted checkmark or X icon instead of a Unicode character.

nautobot.apps.tables.ButtonsColumn

Bases: TemplateColumn

Render edit, delete, and changelog buttons for an object.

:param model: Model class to use for calculating URL view names :param prepend_template: Additional template content to render in the column (optional) :param return_url_extra: String to append to the return URL (e.g. for specifying a tab) (optional)

nautobot.apps.tables.ChoiceFieldColumn

Bases: Column

Render a ChoiceField value inside a indicating a particular CSS class. This is useful for displaying colored choices. The CSS class is derived by calling .get_FOO_class() on the row record.

nautobot.apps.tables.ColorColumn

Bases: Column

Display a color (#RRGGBB).

nautobot.apps.tables.ColoredLabelColumn

Bases: TemplateColumn

Render a colored label (e.g. for DeviceRoles).

nautobot.apps.tables.ComputedFieldColumn

Bases: Column

Display computed fields in the appropriate format.

nautobot.apps.tables.ContentTypesColumn

Bases: ManyToManyColumn

Display a list of content_types m2m assigned to an object.

Default sorting of content-types is by pk. This sorting comes at a per-row performance hit to querysets for table views. If this becomes an issue, set sort_items=False.

:param sort_items: Whether to sort by (app_label, name). (default: True) :param truncate_words: Number of words at which to truncate, or None to disable. (default: None)

filter(qs)

Overload filter to optionally sort items.

render(value)

Overload render to optionally truncate words.

nautobot.apps.tables.CustomFieldColumn

Bases: Column

Display custom fields in the appropriate format.

nautobot.apps.tables.LinkedCountColumn

Bases: Column

Render a count of related objects linked to a filtered URL.

:param viewname: The view name to use for URL resolution :param view_kwargs: Additional kwargs to pass for URL resolution (optional) :param url_params: A dict of query parameters to append to the URL (e.g. ?foo=bar) (optional) :param reverse_lookup: The reverse lookup parameter to use to derive the count. If not specified, the first key in url_params will be implicitly used as the reverse_lookup value.

nautobot.apps.tables.RelationshipColumn

Bases: Column

Display relationship association instances in the appropriate format.

nautobot.apps.tables.RoleTableMixin

Bases: BaseTable

Mixin to add a role field to a table.

nautobot.apps.tables.StatusTableMixin

Bases: BaseTable

Mixin to add a status field to a table.

nautobot.apps.tables.TableExtension

Template class for extending Tables.

An app can override the default columns for a table by either: - Extending the original default columns to include custom columns. - add_to_default_columns = ("my_app_name_new_column",) - Removing native columns from the default columns. - remove_from_default_columns = ("tenant",)

alter_queryset(queryset) classmethod

Alter the View class QuerySet.

This is a good place to add prefetch_related to the view queryset. example: return queryset.prefetch_related("my_model_set")

nautobot.apps.tables.TagColumn

Bases: TemplateColumn

Display a list of tags assigned to the object.

nautobot.apps.tables.ToggleColumn

Bases: CheckBoxColumn

Extend CheckBoxColumn to add a "toggle all" checkbox in the column header.