Use select2 for custom script ObjectVar fields #2886

Closed
opened 2025-12-29 18:23:05 +01:00 by adam · 5 comments
Owner

Originally created by @tkupari on GitHub (Sep 19, 2019).

Environment

  • Python version: 3.7.4
  • NetBox version: 2.6.3

Proposed Functionality

Use select2 to enable filtering in custom script ObjectVar dropdown.

Use Case

Selecting a rack from a list of 300 racks

Database Changes

no

External Dependencies

no

Originally created by @tkupari on GitHub (Sep 19, 2019). <!-- NOTE: 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.4 <!-- Example: 3.5.4 --> * NetBox version: 2.6.3 <!-- Example: 2.3.6 --> <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Use select2 to enable filtering in custom script ObjectVar dropdown. <!-- 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 Selecting a rack from a list of 300 racks <!-- 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 no <!-- 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 no
adam added the status: duplicate label 2025-12-29 18:23:05 +01:00
adam closed this issue 2025-12-29 18:23:05 +01:00
Author
Owner

@DanSheps commented on GitHub (Sep 19, 2019):

I think one thing to look at, would also be to make all vars Select. However, for the select2 for objects, you would need "widget=APISelect", because you can filter a rack with select2, but unless you add in the widget to perform the query, the list is going to be static.

@DanSheps commented on GitHub (Sep 19, 2019): I think one thing to look at, would also be to make all vars Select. However, for the select2 for objects, you would need "widget=APISelect", because you can filter a rack with select2, but unless you add in the widget to perform the query, the list is going to be static.
Author
Owner

@Grokzen commented on GitHub (Oct 8, 2019):

@DanSheps I tried to use ObjectVar with our IPAddress model that had 27k+ objects in it. The page almost crashed on my laptop. The APISelect solution must be there to work the same way as it does on the filter panels on the list views. Yes the current select box works for very small data sets, but bigger ones, no wai.

@Grokzen commented on GitHub (Oct 8, 2019): @DanSheps I tried to use ObjectVar with our IPAddress model that had 27k+ objects in it. The page almost crashed on my laptop. The APISelect solution must be there to work the same way as it does on the filter panels on the list views. Yes the current select box works for very small data sets, but bigger ones, no wai.
Author
Owner

@tyler-8 commented on GitHub (Oct 29, 2019):

This would be extremely useful. There are workflows that, even when using filtered QuerySets, could provide several thousand or more object choices. That would be a browser killer as @Grokzen noted.

@tyler-8 commented on GitHub (Oct 29, 2019): This would be extremely useful. There are workflows that, even when using filtered QuerySets, could provide several thousand or more object choices. That would be a browser killer as @Grokzen noted.
Author
Owner

@hSaria commented on GitHub (Jan 13, 2020):

I'm all for implementing this, but we'd need to address the issue with manually specifying the api_url of the APISelect-based widgets; someone is bound to put the wrong URL. Maybe we create an API URL attribute for every model to be used in the data-url attribute of the select field.

@hSaria commented on GitHub (Jan 13, 2020): I'm all for implementing this, but we'd need to address the issue with manually specifying the `api_url` of the APISelect-based widgets; someone is bound to put the wrong URL. Maybe we create an API URL attribute for every model to be used in the `data-url` attribute of the select field.
Author
Owner

@hSaria commented on GitHub (Jan 25, 2020):

Could this be closed as it is a duplicate of #3766 (has more relevant information, I'd say)

@hSaria commented on GitHub (Jan 25, 2020): Could this be closed as it is a duplicate of #3766 (has more relevant information, I'd say)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2886