Преглед изворни кода

Set a default self.to_field_name for FilterChoiceField

Jeremy Stretch пре 6 година
родитељ
комит
5008526db1
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      netbox/utilities/forms.py

+ 1 - 1
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
         # 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.
         if bound_field.data:
         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)
             self.queryset = self.queryset.filter(**kwargs)
         else:
         else:
             self.queryset = self.queryset.none()
             self.queryset = self.queryset.none()