Plugins: Extend Create and Edit Object view to include custom forms. #3777

Closed
opened 2025-12-29 18:31:10 +01:00 by adam · 1 comment
Owner

Originally created by @minitriga on GitHub (Jun 12, 2020).

Environment

  • Python version: 3.7
  • NetBox version: 2.8.0

Proposed Functionality

Allow users to fill out plugin information within the object create/edit view. Currently, we are using Custom Fields to do this but it would be nice to have a form that ties to its own model if required as using Custom Fields means we need to keep track of what custom fields we are using.

image

from extras.plugins import PluginTemplateExtension
from django import forms

class NameForm(forms.Form):
    test_1 = forms.CharField(label='Test 1', max_length=100)
    test_2 = forms.CharField(label='Test 2', max_length=100)

class DeviceTypeListForm(PluginTemplateExtension):
    model = 'dcim.device_type'
    form = NameForm()
    def form(self):
        return form

template_extensions = [DeviceTypeListForm]

I'm not sure of the implementation details but let me know if this doesn't make sense.

Shouldnt need to do anything with the view template as there are already components that allow this detail to be added.

Use Case

Ability to populate models that relate within the same view as Netbox Core models.

Database Changes

None

External Dependencies

Netbox Plugins

Originally created by @minitriga on GitHub (Jun 12, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/forum/#!forum/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7 * NetBox version: 2.8.0 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Allow users to fill out plugin information within the object create/edit view. Currently, we are using Custom Fields to do this but it would be nice to have a form that ties to its own model if required as using Custom Fields means we need to keep track of what custom fields we are using. ![image](https://user-images.githubusercontent.com/26367336/84517228-e5600a00-acc6-11ea-8818-a5a41f7ff116.png) ``` from extras.plugins import PluginTemplateExtension from django import forms class NameForm(forms.Form): test_1 = forms.CharField(label='Test 1', max_length=100) test_2 = forms.CharField(label='Test 2', max_length=100) class DeviceTypeListForm(PluginTemplateExtension): model = 'dcim.device_type' form = NameForm() def form(self): return form template_extensions = [DeviceTypeListForm] ``` I'm not sure of the implementation details but let me know if this doesn't make sense. Shouldnt need to do anything with the view template as there are already components that allow this detail to be added. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case Ability to populate models that relate within the same view as Netbox Core models. <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes None <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies Netbox Plugins
adam closed this issue 2025-12-29 18:31:10 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 12, 2020):

It's a neat idea, but this isn't something we can reasonably support in the core. Forms can be very complex, particularly with regard to validation, and trying to accommodate unknown third party extensions is a non-starter. Further, our goal is to eventually move toward an entirely API-driven UI anyway, which would obviate the need for traditional forms as they currently exist.

@jeremystretch commented on GitHub (Jun 12, 2020): It's a neat idea, but this isn't something we can reasonably support in the core. Forms can be very complex, particularly with regard to validation, and trying to accommodate unknown third party extensions is a non-starter. Further, our goal is to eventually move toward an entirely API-driven UI anyway, which would obviate the need for traditional forms as they currently exist.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3777