From 5008526db145059f66031f2e7b0fc6180327ed22 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 10 Feb 2020 10:08:20 -0500 Subject: [PATCH] Set a default self.to_field_name for FilterChoiceField --- netbox/utilities/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py index 85fb762bb..cd78b249e 100644 --- a/netbox/utilities/forms.py +++ b/netbox/utilities/forms.py @@ -596,7 +596,7 @@ class FilterChoiceField(forms.ModelMultipleChoiceField): # 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. if bound_field.data: - kwargs = {'{}__in'.format(self.to_field_name): bound_field.data} + kwargs = {'{}__in'.format(self.to_field_name or 'pk'): bound_field.data} self.queryset = self.queryset.filter(**kwargs) else: self.queryset = self.queryset.none()