1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add initial_params to all forms

This commit is contained in:
Jeremy Stretch
2020-11-04 11:09:13 -05:00
parent 1f0b1dd10e
commit 7598b891c1
6 changed files with 25 additions and 60 deletions

View File

@@ -309,7 +309,8 @@ class DynamicModelChoiceMixin:
value = form.initial.get(child_field.lstrip('$'))
if value:
filter_kwargs[kwarg] = value
self.initial = self.queryset.filter(**filter_kwargs).first()
if filter_kwargs:
self.initial = self.queryset.filter(**filter_kwargs).first()
# 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.