Skip to content

Commit fc5d07b

Browse files
Merge pull request #3813 from hSaria/3812-optimize-select-api
Fixes #3812: Only preload selected options for API-based select
2 parents 395f23e + 242ae9e commit fc5d07b

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

docs/release-notes/version-2.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [#3705](https://github.com/netbox-community/netbox/issues/3705) - Provide request context when executing custom scripts
99
* [#3762](https://github.com/netbox-community/netbox/issues/3762) - Add date/time picker widgets
1010
* [#3788](https://github.com/netbox-community/netbox/issues/3788) - Enable partial search for inventory items
11+
* [#3812](https://github.com/netbox-community/netbox/issues/3812) - Optimize size of pages containing a dynamic selection field
1112

1213
## Bug Fixes
1314

netbox/utilities/forms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ class APISelect(SelectWithDisabled):
285285
name of the query param and the value if the query param's value.
286286
:param null_option: If true, include the static null option in the selection list.
287287
"""
288+
# Only preload the selected option(s); new options are dynamically displayed and added via the API
289+
template_name = 'widgets/select_api.html'
288290

289291
def __init__(
290292
self,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
2+
<optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected %}
3+
{% include widget.template_name %}{% endif %}{% endfor %}{% if group_name %}
4+
</optgroup>{% endif %}{% endfor %}
5+
</select>

0 commit comments

Comments
 (0)