Adding Extra Tabs¶
Added in version 1.4.0
In order for any extra tabs to work properly, the
"url" key must reference a view which inherits from the
nautobot.apps.views.ObjectView class and the template must extend the object's detail template such as:
Here's a basic example of a tab's view
# views.py from nautobot.apps.views import ObjectView from nautobot.dcim.models import Device class DeviceDetailAppTabOne(ObjectView): """ This view's template extends the device detail template, making it suitable to show as a tab on the device detail page. Views that are intended to be for an object detail tab's content rendering must always inherit from nautobot.apps.views.ObjectView. """ queryset = Device.objects.all() template_name = "example_plugin/tab_device_detail_1.html"
You must also add the view to the
url_patterns like so (make sure to read the note after this code snippet):
For added tab views, we recommend for consistency that you follow the URL pattern established by the base model detail view and tabs (if any). For example,
nautobot/dcim/urls.py references Device tab views with the URL pattern
devices/<uuid:pk>/TAB-NAME/, so above we have followed that same pattern.