Add initial_params to all forms

This commit is contained in:
Jeremy Stretch
2020-11-04 11:09:13 -05:00
parent b2348fa656
commit 85d16cf0a6
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.