Calculated "custom view" fields #9045

Closed
opened 2025-12-29 20:44:44 +01:00 by adam · 4 comments
Owner

Originally created by @8ctorres on GitHub (Jan 5, 2024).

NetBox version

v3.5.1

Feature type

Data model extension

Proposed functionality

Include a new custom "thing", besides custom fields and custom links, could be called "custom view".
This custom view field contains a Jinja2 template that allows showing already existing information in a different format. This is always read-only by nature, since it doesn't store any information of its own.

Use case

Enables the possibility of showing in the web UI, filtering, sorting by it, and exporting to CSV some case-specific information that is pertinent to the model but not contained in itself.

For instance, a custom field for Sites that shows the total capacity of all circuits that are connected to that site, or shows how many different providers have a circuit connected to that site. I could store this information on a custom field as a string, but that will end up causing problems if someone changes the actual circuit information and doesn't edit the custom field accordingly.

For API consumers this is kind of irrelevant, since any logic can be done on the client side, but for web UI users I think it's actually useful.

Edit:

This field would applicable to other kinds of objects, not only sites. Another example would be with Circuits. Imagine I need to know the manufacturer of the device that each circuit is connected to. I could have a field with a template such as "{{ this.termination_a.link_peers[0].device.device_type.manufacturer.name }}". This is just an example, what I'm proposing is in general, a way to display information that may be relevant to the object, even if this piece of information is not contained in the object itself, but some number of steps away, or in a situation where the origin object doesn't have a direct relationship to the information you're searching, but instead is the other way around (as in the example I said before with the sites, sites don't have any attribute that points to their circuits, instead it's the circuits that point to the site they're connected to...)

Database changes

Add a new model "Custom view field" (not really sure of the name, open to suggestions)

External dependencies

No response

Originally created by @8ctorres on GitHub (Jan 5, 2024). ### NetBox version v3.5.1 ### Feature type Data model extension ### Proposed functionality Include a new custom "thing", besides custom fields and custom links, could be called "custom view". This custom view field contains a Jinja2 template that allows showing already existing information in a different format. This is always read-only by nature, since it doesn't store any information of its own. ### Use case Enables the possibility of showing in the web UI, filtering, sorting by it, and exporting to CSV some case-specific information that is pertinent to the model but not contained in itself. For instance, a custom field for Sites that shows the total capacity of all circuits that are connected to that site, or shows how many different providers have a circuit connected to that site. I could store this information on a custom field as a string, but that will end up causing problems if someone changes the actual circuit information and doesn't edit the custom field accordingly. For API consumers this is kind of irrelevant, since any logic can be done on the client side, but for web UI users I think it's actually useful. Edit: This field would applicable to other kinds of objects, not only sites. Another example would be with Circuits. Imagine I need to know the manufacturer of the device that each circuit is connected to. I could have a field with a template such as "{{ this.termination_a.link_peers[0].device.device_type.manufacturer.name }}". This is just an example, what I'm proposing is in general, a way to display information that may be relevant to the object, even if this piece of information is not contained in the object itself, but some number of steps away, or in a situation where the origin object doesn't have a direct relationship to the information you're searching, but instead is the other way around (as in the example I said before with the sites, sites don't have any attribute that points to their circuits, instead it's the circuits that point to the site they're connected to...) ### Database changes Add a new model "Custom view field" (not really sure of the name, open to suggestions) ### External dependencies _No response_
adam added the type: featureplugin candidate labels 2025-12-29 20:44:44 +01:00
adam closed this issue 2025-12-29 20:44:44 +01:00
Author
Owner

@jeffgdotorg commented on GitHub (Jan 5, 2024):

Thanks for your interest in helping improve NetBox!

We need some additional information to help us understand your proposal. Please update your original report to reflect the following:

  1. In use case, flesh out your example for Sites to include an example Jinja2 template that you imagine might work for each derived value that you identify.
  2. In use case, please indicate whether the proposed functionality should be specific to Sites, or if it's applicable to other kinds of objects and therefore ought to be more generic in nature.

Additionally, as something to think about, have you considered implementing the proposed functionality (or a prototype of it) in a plugin?

@jeffgdotorg commented on GitHub (Jan 5, 2024): Thanks for your interest in helping improve NetBox! We need some additional information to help us understand your proposal. Please update your original report to reflect the following: 1. In **use case**, flesh out your example for Sites to include an example Jinja2 template that you imagine might work for each derived value that you identify. 2. In **use case**, please indicate whether the proposed functionality should be specific to Sites, or if it's applicable to other kinds of objects and therefore ought to be more generic in nature. Additionally, as something to think about, have you considered implementing the proposed functionality (or a prototype of it) in a plugin?
Author
Owner

@8ctorres commented on GitHub (Jan 10, 2024):

Hello @jeffgdotorg

Sorry for the late response, I was out of a few days. I just edited the original message answering your two questions. As for if I have considered developing a plugin, I'm not familiar with the development process for a plugin, neither with how tight the integration of such a plugin could be. Could a plugin generated field be displayed in the table alongside netbox's own fields?

Thanks!

@8ctorres commented on GitHub (Jan 10, 2024): Hello @jeffgdotorg Sorry for the late response, I was out of a few days. I just edited the original message answering your two questions. As for if I have considered developing a plugin, I'm not familiar with the development process for a plugin, neither with how tight the integration of such a plugin could be. Could a plugin generated field be displayed in the table alongside netbox's own fields? Thanks!
Author
Owner

@github-actions[bot] commented on GitHub (May 15, 2024):

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 (May 15, 2024): 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/develop/CONTRIBUTING.md).
Author
Owner

@jeffgdotorg commented on GitHub (May 17, 2024):

Thank you for submitting your idea. Although the proposed functionality falls outside the current scope of NetBox's core feature set, it may make a good candidate for a NetBox plugin, and we encourage you to pursue its development and a standalone project. Please reach out via our mailing list or Slack channel if you need any assistance.

@jeffgdotorg commented on GitHub (May 17, 2024): Thank you for submitting your idea. Although the proposed functionality falls outside the current scope of NetBox's core feature set, it may make a good candidate for a [NetBox plugin](https://netbox.readthedocs.io/en/stable/plugins/), and we encourage you to pursue its development and a standalone project. Please reach out [via our mailing list or Slack channel](https://github.com/netbox-community/netbox/wiki) if you need any assistance.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9045