Adding additional custom tabs to non-detail views #10835

Closed
opened 2025-12-29 21:36:28 +01:00 by adam · 5 comments
Owner

Originally created by @aa659 on GitHub (Mar 2, 2025).

NetBox version

v4.2.4

Feature type

Change to existing functionality

Proposed functionality

With https://github.com/netbox-community/netbox/pull/18029 adding support for registering non-detail custom views via register_model_view(detail=False), would it be possible to also add support for adding tabs for these views (via the ViewTab class)?

Currently, only ObjectView uses the tab field, so I presume this would have to be moved up one level to the BaseObjectView/BaseMultiObjectView classes, and the templates updated to dynamically insert the tabs similar to how generic/object.html does:

{# Include tabs for registered model views #}
{% model_view_tabs object %}

(Since a non-detail view can either be a list, edit or delete view, it would probably be necessary to specify or identify what type of view we want to add the tab to?)

Use case

My plugin adds a "Quick Create" view with a custom form to make it easier to bulk create prefixes, IPs and interfaces for a specified device. I have registered my custom view as such:

@register_model_view(model=Prefix, name='quick_add', detail=False)
class PrefixQuickCreateView(View):
# ...

which makes it available under /ipam/prefixes/quick-add/, however I'd also like to add a corresponding "Quick Create" custom tab which would show up when navigating to /ipam/prefixes/add/ (i.e PrefixEditView)

Database changes

No response

External dependencies

No response

Originally created by @aa659 on GitHub (Mar 2, 2025). ### NetBox version v4.2.4 ### Feature type Change to existing functionality ### Proposed functionality With https://github.com/netbox-community/netbox/pull/18029 adding support for registering non-detail custom views via `register_model_view(detail=False)`, would it be possible to also add support for adding tabs for these views (via the [`ViewTab`](https://github.com/netbox-community/netbox/blob/3b1daaaad66e76219c1dff9f893297aae9ea9a30/netbox/utilities/views.py#L205-L242) class)? Currently, only `ObjectView` uses the [`tab`](https://github.com/netbox-community/netbox/blob/3b1daaaad66e76219c1dff9f893297aae9ea9a30/netbox/netbox/views/generic/object_views.py#L46) field, so I presume this would have to be moved up one level to the `BaseObjectView`/`BaseMultiObjectView` classes, and the templates updated to dynamically insert the tabs similar to how [`generic/object.html`](https://github.com/netbox-community/netbox/blob/3b1daaaad66e76219c1dff9f893297aae9ea9a30/netbox/templates/generic/object.html#L112-L113) does: ```jinja2 {# Include tabs for registered model views #} {% model_view_tabs object %} ``` _(Since a non-detail view can either be a list, edit or delete view, it would probably be necessary to specify or identify what type of view we want to add the tab to?)_ ### Use case My plugin adds a "Quick Create" view with a custom form to make it easier to bulk create prefixes, IPs and interfaces for a specified device. I have registered my custom view as such: ```python @register_model_view(model=Prefix, name='quick_add', detail=False) class PrefixQuickCreateView(View): # ... ``` which makes it available under `/ipam/prefixes/quick-add/`, however I'd also like to add a corresponding _"Quick Create"_ custom tab which would show up when navigating to `/ipam/prefixes/add/` (i.e [`PrefixEditView`](https://github.com/netbox-community/netbox/blob/3b1daaaad66e76219c1dff9f893297aae9ea9a30/netbox/ipam/views.py#L656-L658)) ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurepending closurestatus: under review labels 2025-12-29 21:36:28 +01:00
adam closed this issue 2025-12-29 21:36:29 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 6, 2025):

however I'd also like to add a corresponding "Quick Create" custom tab which would show up when navigating to /ipam/prefixes/add/

To clarify, do you mean to have an alternative tab render next to the "Create" tab, like what NetBox currently does on the creation page for IP addresses?

@jeremystretch commented on GitHub (Mar 6, 2025): > however I'd also like to add a corresponding "Quick Create" custom tab which would show up when navigating to `/ipam/prefixes/add/` To clarify, do you mean to have an alternative tab render next to the "Create" tab, like what NetBox currently does on the creation page for IP addresses?
Author
Owner

@aa659 commented on GitHub (Mar 7, 2025):

however I'd also like to add a corresponding "Quick Create" custom tab which would show up when navigating to /ipam/prefixes/add/

To clarify, do you mean to have an alternative tab render next to the "Create" tab, like what NetBox currently does on the creation page for IP addresses?

Yes exactly. Like this:

Image

@aa659 commented on GitHub (Mar 7, 2025): > > however I'd also like to add a corresponding "Quick Create" custom tab which would show up when navigating to `/ipam/prefixes/add/` > > To clarify, do you mean to have an alternative tab render next to the "Create" tab, like what NetBox currently does on the creation page for IP addresses? Yes exactly. Like this: ![Image](https://github.com/user-attachments/assets/c95d8877-91da-4bcb-aea9-d621e3294c5a)
Author
Owner

@jeremystretch commented on GitHub (Mar 7, 2025):

I'm not sure how we'd go about that to be honest; the tab registration system currently supports only the detail view for an object. We would need to introduce the concept of view action (detail, list, add, etc.) as part of the tab registration mechanism.

@jeremystretch commented on GitHub (Mar 7, 2025): I'm not sure how we'd go about that to be honest; the tab registration system currently supports only the detail view for an object. We would need to introduce the concept of view action (detail, list, add, etc.) as part of the tab registration mechanism.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 6, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jun 6, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/main/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jul 6, 2025):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jul 6, 2025): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10835