소스 검색

Call prepare_value() to avoid passing model instances directly to the filterset

Jeremy Stretch 6 년 전
부모
커밋
25d126d4ff
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      netbox/utilities/forms.py

+ 1 - 1
netbox/utilities/forms.py

@@ -572,7 +572,7 @@ 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.data or bound_field.initial
+        data = self.prepare_value(bound_field.data or bound_field.initial)
         if data:
         if data:
             filter = self.filter(field_name=self.to_field_name or 'pk', queryset=self.queryset)
             filter = self.filter(field_name=self.to_field_name or 'pk', queryset=self.queryset)
             self.queryset = filter.filter(self.queryset, data)
             self.queryset = filter.filter(self.queryset, data)