plugins: filter in forms.py #13119
-
Netbox ver 3.5.4 How do you set a filter in forms.py to only show desired list in DynamicModelChoiceField? Here is an example ( SiteGroup.objects.filter(name__icontains="L3") ). It works from nbshell. class L3SiteForm(NetBoxModelForm):
sitegroup = DynamicModelChoiceField(
queryset=SiteGroup.objects.filter(name__icontains="L3")
)
l3vrf = DynamicModelMultipleChoiceField(
queryset=VRF.objects.all(),
required=False,
) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Just search the source for |
Beta Was this translation helpful? Give feedback.
Here is the solution for me.