Skip to content

nautobot.apps.ui

Utilities for apps to integrate with and extend the existing Nautobot UI.

nautobot.apps.ui.Banner

Class that may be returned by a registered plugin_banners function.

nautobot.apps.ui.BannerClassChoices

Bases: ChoiceSet

Styling choices for custom banners.

nautobot.apps.ui.ButtonColorChoices

Bases: ChoiceSet

Map standard button color choices to Bootstrap color classes

nautobot.apps.ui.HomePageBase

Bases: ABC

Base class for homepage layout classes.

nautobot.apps.ui.HomePageGroup

Bases: HomePageBase, PermissionsMixin

Defines properties that can be used for a panel group.

__init__(name, permissions=None, items=None, weight=1000)

Ensure group properties.

Parameters:

Name Type Description Default
name str

The name of the group.

required
permissions list

The permissions required to view this group.

None
items list

List of items to be rendered in this group.

None
weight int

The weight of this group.

1000

nautobot.apps.ui.HomePageItem

Bases: HomePageBase, PermissionsMixin

Defines properties that can be used for a panel item.

__init__(name, link=None, model=None, custom_template=None, custom_data=None, description=None, permissions=None, weight=1000)

Ensure item properties.

Parameters:

Name Type Description Default
name str

The name of the item.

required
link str

The link to be used for this item.

None
model str

The model to being used for this item to calculate the total count of objects.

None
custom_template str

Name of custom template.

None
custom_data dict

Custom data to be passed to the custom template.

None

nautobot.apps.ui.HomePagePanel

Bases: HomePageBase, PermissionsMixin

Defines properties that can be used for a panel.

__init__(name, permissions=None, custom_data=None, custom_template=None, items=None, weight=1000)

Ensure panel properties.

Parameters:

Name Type Description Default
name str

The name of the panel.

required
permissions list

The permissions required to view this panel.

None
custom_data dict

Custom data to be passed to the custom template.

None
custom_template str

Name of custom template.

None
items list

List of items to be rendered in this panel.

None
weight int

The weight of this panel.

1000

nautobot.apps.ui.NavContext

Bases: NavMenuBase

Ths class represents a navigation menu tab for new ui.

Groups are each specified as a list of NavGrouping instances.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

nautobot.apps.ui.NavGrouping

Bases: NavMenuBase, PermissionsMixin

Ths class represents a navigation menu group for the new ui. This is built up from a name and a weight value. The name is the display text and the weight defines its position in the navigation sidebar.

Items are each specified as a list of NavItem or NavGrouping instances.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

nautobot.apps.ui.NavItem

Bases: NavMenuBase, PermissionsMixin

This class represents a navigation menu item for the new ui. This constitutes link and its text.

Links are specified as Django reverse URL strings.

fixed_fields property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

nautobot.apps.ui.NavMenuAddButton

Bases: NavMenuButton

Add button subclass.

__init__(*args, **kwargs)

Ensure button properties.

nautobot.apps.ui.NavMenuBase

Bases: ABC

Base class for navigation classes.

fixed_fields: tuple abstractmethod property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict abstractmethod property

Attributes to be stored when adding this item to the nav menu data for the first time.

nautobot.apps.ui.NavMenuButton

Bases: NavMenuBase, PermissionsMixin

This class represents a button within a NavMenuItem.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

__init__(link, title, icon_class, button_class=ButtonActionColorChoices.DEFAULT, permissions=None, weight=1000)

Ensure button properties.

Parameters:

Name Type Description Default
link str

The link to be used for this button.

required
title str

The title of the button.

required
icon_class str

The icon class to be used as the icon for the start of the button.

required
button_class str

The button class defines to be used to define the style of the button.

DEFAULT
permissions list

The permissions required to view this button.

None
weight int

The weight of this button.

1000

nautobot.apps.ui.NavMenuGroup

Bases: NavMenuBase, PermissionsMixin

Ths class represents a navigation menu group. This is built up from a name and a weight value. The name is the display text and the weight defines its position in the navbar.

Items are each specified as a list of NavMenuItem instances.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

__init__(name, items=None, weight=1000)

Ensure group properties.

Parameters:

Name Type Description Default
name str

The name of the group.

required
items list

List of items to be rendered in this group.

None
weight int

The weight of this group.

1000

nautobot.apps.ui.NavMenuImportButton

Bases: NavMenuButton

Import button subclass.

__init__(*args, **kwargs)

Ensure button properties.

nautobot.apps.ui.NavMenuItem

Bases: NavMenuBase, PermissionsMixin

This class represents a navigation menu item. This constitutes primary link and its text, but also allows for specifying additional link buttons that appear to the right of the item in the nav menu.

Links are specified as Django reverse URL strings. Buttons are each specified as a list of NavMenuButton instances.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

__init__(link, name, args=None, kwargs=None, permissions=None, buttons=(), weight=1000)

Ensure item properties.

Parameters:

Name Type Description Default
link str

The link to be used for this item.

required
name str

The name of the item.

required
args list

Arguments that are being passed to the url with reverse() method

None
kwargs dict

Keyword arguments are are being passed to the url with reverse() method

None
permissions list

The permissions required to view this item.

None
buttons list

List of buttons to be rendered in this item.

()
weight int

The weight of this item.

1000

nautobot.apps.ui.NavMenuTab

Bases: NavMenuBase, PermissionsMixin

Ths class represents a navigation menu tab. This is built up from a name and a weight value. The name is the display text and the weight defines its position in the navbar.

Groups are each specified as a list of NavMenuGroup instances.

fixed_fields: tuple property

Tuple of (name, attribute) entries describing fields that may not be altered after declaration.

initial_dict: dict property

Attributes to be stored when adding this item to the nav menu data for the first time.

__init__(name, permissions=None, groups=None, weight=1000)

Ensure tab properties.

Parameters:

Name Type Description Default
name str

The name of the tab.

required
permissions list

The permissions required to view this tab.

None
groups list

List of groups to be rendered in this tab.

None
weight int

The weight of this tab.

1000

nautobot.apps.ui.PermissionsMixin

Ensure permissions through init.

__init__(permissions=None)

Ensure permissions.

nautobot.apps.ui.TemplateExtension

This class is used to register plugin content to be injected into core Nautobot templates. It contains methods that are overridden by plugin authors to return template content.

The model attribute on the class defines the which model detail page this class renders content for. It should be set as a string in the form <app_label>.<model_name>. render() provides the following context data:

  • object - The object being viewed
  • request - The current request
  • settings - Global Nautobot settings
  • config - Plugin-specific configuration parameters

buttons()

Buttons that will be rendered and added to the existing list of buttons on the detail page view. Content should be returned as an HTML string. Note that content does not need to be marked as safe because this is automatically handled.

detail_tabs()

Tabs that will be rendered and added to the existing list of tabs on the detail page view. Tabs will be ordered by their position in the list.

Content should be returned as a list of dicts in the following format:

[
    {
        "title": "<title>",
        "url": "<url for the tab link>",
    },
    {
        "title": "<title>",
        "url": "<url for the tab link>",
    },
]

full_width_page()

Content that will be rendered within the full width of the detail page view. Content should be returned as an HTML string. Note that content does not need to be marked as safe because this is automatically handled.

left_page()

Content that will be rendered on the left of the detail page view. Content should be returned as an HTML string. Note that content does not need to be marked as safe because this is automatically handled.

list_buttons()

Buttons that will be rendered and added to the existing list of buttons on the list page view. Content should be returned as an HTML string. Note that content does not need to be marked as safe because this is automatically handled.

render(template_name, extra_context=None)

Convenience method for rendering the specified Django template using the default context data. An additional context dictionary may be passed as extra_context.

right_page()

Content that will be rendered on the right of the detail page view. Content should be returned as an HTML string. Note that content does not need to be marked as safe because this is automatically handled.