mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Improve APISelect query parameter handling (#7040)
* Fixes #7035: Refactor APISelect query_param logic * Add filter_fields to extras.ObjectVar & fix default value handling * Update ObjectVar docs to reflect new filter_fields attribute * Revert changes from89b7f3f
* Maintain current `query_params` API for form fields, transform data structure in widget * Revert changes fromd0208d4
This commit is contained in:
@ -375,8 +375,8 @@ class DynamicModelChoiceMixin:
|
||||
filter = django_filters.ModelChoiceFilter
|
||||
widget = widgets.APISelect
|
||||
|
||||
def __init__(self, query_params=None, initial_params=None, null_option=None, disabled_indicator=None, fetch_trigger=None, *args,
|
||||
**kwargs):
|
||||
def __init__(self, query_params=None, initial_params=None, null_option=None, disabled_indicator=None, fetch_trigger=None,
|
||||
*args, **kwargs):
|
||||
self.query_params = query_params or {}
|
||||
self.initial_params = initial_params or {}
|
||||
self.null_option = null_option
|
||||
@ -409,8 +409,8 @@ class DynamicModelChoiceMixin:
|
||||
attrs['data-fetch-trigger'] = self.fetch_trigger
|
||||
|
||||
# Attach any static query parameters
|
||||
for key, value in self.query_params.items():
|
||||
widget.add_query_param(key, value)
|
||||
if (len(self.query_params) > 0):
|
||||
widget.add_query_params(self.query_params)
|
||||
|
||||
return attrs
|
||||
|
||||
|
Reference in New Issue
Block a user