mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 03:27:21 -06:00
Make sure initial data is passed as array for DynamicModelChoiceFields
This commit is contained in:
parent
2e5a5f71ba
commit
6d3cded579
@ -88,7 +88,12 @@ class DynamicModelChoiceMixin:
|
|||||||
# Modify the QuerySet of the field before we return it. Limit choices to any data already bound: Options
|
# Modify the QuerySet of the field before we return it. Limit choices to any data already bound: Options
|
||||||
# will be populated on-demand via the APISelect widget.
|
# will be populated on-demand via the APISelect widget.
|
||||||
data = bound_field.value()
|
data = bound_field.value()
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
|
# When the field is multiple choice pass the data as a list if it's not already
|
||||||
|
if isinstance(bound_field.field, DynamicModelMultipleChoiceField) and not type(data) is list:
|
||||||
|
data = [data]
|
||||||
|
|
||||||
field_name = getattr(self, 'to_field_name') or 'pk'
|
field_name = getattr(self, 'to_field_name') or 'pk'
|
||||||
filter = self.filter(field_name=field_name)
|
filter = self.filter(field_name=field_name)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user