Support the use of NetBox's generic views by plugins #5934

Closed
opened 2025-12-29 19:34:27 +01:00 by adam · 9 comments
Owner

Originally created by @jeremystretch on GitHub (Jan 12, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.1.5

Feature type

New functionality

Proposed functionality

Formally support and document the use of NetBox's generic view classes by plugins. These are to include initially:

  • ObjectView
  • ObjectEditView
  • ObjectDeleteView
  • ObjectListView
  • BulkImportView
  • BulkEditView
  • BulkDeleteView

Additional views may also be added or created depending on feedback from plugin authors.

Most of these classes likely must undergo so amount of refactoring and formalization to ensure a degree of maturity suitable for the inclusion in a public framework.

Use case

Much like Django's own generic views, use of these views enables plugin authors to avoid writing a substantial amount of boilerplate code.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Jan 12, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.1.5 ### Feature type New functionality ### Proposed functionality Formally support and document the use of NetBox's generic view classes by plugins. These are to include initially: - ObjectView - ObjectEditView - ObjectDeleteView - ObjectListView - BulkImportView - BulkEditView - BulkDeleteView Additional views may also be added or created depending on feedback from plugin authors. Most of these classes likely must undergo so amount of refactoring and formalization to ensure a degree of maturity suitable for the inclusion in a public framework. ### Use case Much like Django's own [generic views](https://docs.djangoproject.com/en/stable/ref/class-based-views/), use of these views enables plugin authors to avoid writing a substantial amount of boilerplate code. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: featuretopic: plugins labels 2025-12-29 19:34:27 +01:00
adam closed this issue 2025-12-29 19:34:27 +01:00
Author
Owner

@johannwagner commented on GitHub (Jan 20, 2022):

Hey,

we actually implemented this functionality within a quite hacky plugin our my employer. We could contribute an initial implementation. Is this the desired approach?

Best Regards,
Johann

@johannwagner commented on GitHub (Jan 20, 2022): Hey, we actually implemented this functionality within a quite hacky plugin our my employer. We could contribute an initial implementation. Is this the desired approach? Best Regards, Johann
Author
Owner

@jeremystretch commented on GitHub (Jan 20, 2022):

@johannwagner I think for the most part this amounts to "hardening" the existing view classes to make them suitable for use outside NetBox core. I'd be interested to see what changes you made. Is there a way you could share a summary, short of drafting a whole PR?

@jeremystretch commented on GitHub (Jan 20, 2022): @johannwagner I think for the most part this amounts to "hardening" the existing view classes to make them suitable for use outside NetBox core. I'd be interested to see what changes you made. Is there a way you could share a summary, short of drafting a whole PR?
Author
Owner

@johannwagner commented on GitHub (Jan 20, 2022):

Mostly it's fixing up the url names because of the plugin prefix. The rest "just works" but lacks a lot of documentation, because the public use wasn't intended yet.

@johannwagner commented on GitHub (Jan 20, 2022): Mostly it's fixing up the url names because of the plugin prefix. The rest "just works" but lacks a lot of documentation, because the public use wasn't intended yet.
Author
Owner

@jeremystretch commented on GitHub (Jan 20, 2022):

@johannwagner Roger. I know @DanSheps was working on that recently in the 6221-pluginviews branch; does that look similar to your tweaks?

@jeremystretch commented on GitHub (Jan 20, 2022): @johannwagner Roger. I know @DanSheps was working on that recently in the [`6221-pluginviews` branch](https://github.com/netbox-community/netbox/tree/6221-pluginviews); does that look similar to your tweaks?
Author
Owner

@johannwagner commented on GitHub (Jan 20, 2022):

Yup, we have similar patches, I just looked it up.
We have patches for:

  • viewname and validated_viewname template tags for the plugin prefix
  • ButtonsColumn also to implement the plugin prefix.

Those patches enables us to write plugin with newly introduced models with almost no boilerplate. Most boilerplate code comes from the <modelname>.html of the generic object view, which could be eliminated by some finer block overrides.

@johannwagner commented on GitHub (Jan 20, 2022): Yup, we have similar patches, I just looked it up. We have patches for: - `viewname` and `validated_viewname` template tags for the plugin prefix - ButtonsColumn also to implement the plugin prefix. Those patches enables us to write plugin with newly introduced models with almost no boilerplate. Most boilerplate code comes from the `<modelname>.html` of the generic object view, which could be eliminated by some finer block overrides.
Author
Owner

@johannwagner commented on GitHub (Jan 20, 2022):

I also would like to see a better method of using different tabs within a detailed view, this is kinda hacky right now.

@johannwagner commented on GitHub (Jan 20, 2022): I also would like to see a better method of using different tabs within a detailed view, this is kinda hacky right now.
Author
Owner

@DanSheps commented on GitHub (Jan 21, 2022):

Yeah, now that I see you are going the mkdocstring for documenting the API, I will work on cleaning up the view documentation

@DanSheps commented on GitHub (Jan 21, 2022): Yeah, now that I see you are going the mkdocstring for documenting the API, I will work on cleaning up the view documentation
Author
Owner

@jeremystretch commented on GitHub (Jan 21, 2022):

@DanSheps I've started on this in the 8334-plugin-views branch. I still have some work to do around refactoring & documentation; once that's done I'll fold in your changes from #6221. Then we can reassess scope and decide if there's anything else we need to add for #8334 specifically. Sound good?

@jeremystretch commented on GitHub (Jan 21, 2022): @DanSheps I've started on this in the [`8334-plugin-views` branch](https://github.com/netbox-community/netbox/tree/8334-plugins-views). I still have some work to do around refactoring & documentation; once that's done I'll fold in your changes from #6221. Then we can reassess scope and decide if there's anything else we need to add for #8334 specifically. Sound good?
Author
Owner

@DanSheps commented on GitHub (Jan 21, 2022):

Sounds good with me. I will look into the button class thing, I think I might have covered that, I just need to double check.

@DanSheps commented on GitHub (Jan 21, 2022): Sounds good with me. I will look into the button class thing, I think I might have covered that, I just need to double check.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5934