Skip to content

Enable a PluginTemplateExtension subclass to register for multiple models #16726

Closed
@jeremystretch

Description

@jeremystretch

NetBox version

v4.0.6

Feature type

New functionality

Proposed functionality

A subclass of PluginTemplateExtension must currently register against a single model. For example:

from netbox.plugins import PluginTemplateExtension

class SiteCustomContent(PluginTemplateExtension):
    model = 'dcim.site'

This issue proposes adding an alternative models attribute to specify an iterable of models. For example:

from netbox.plugins import PluginTemplateExtension

class SiteCustomContent(PluginTemplateExtension):
    models = ['dcim.region', 'dcim.site', 'dcim.location']

The content introduced by this class will then be embedded on the relevant view for each of the listed models.

If models is defined, it will take precedence over model.

Use case

This obviates the need to create a redundant PluginTemplateExtension subclass for each core model.

Database changes

None

External dependencies

None

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtopic: pluginsRelates to the plugins frameworktype: featureIntroduction of new functionality to the application

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions