diff --git a/netbox/ipam/filtersets.py b/netbox/ipam/filtersets.py index a72042f5a..017a34ac4 100644 --- a/netbox/ipam/filtersets.py +++ b/netbox/ipam/filtersets.py @@ -1127,10 +1127,16 @@ class VLANTranslationRuleFilterSet(NetBoxModelFilterSet): queryset=VLANTranslationPolicy.objects.all(), label=_('VLAN Translation Policy (ID)'), ) + policy = django_filters.ModelMultipleChoiceFilter( + field_name='policy__name', + queryset=VLANTranslationPolicy.objects.all(), + to_field_name='name', + label=_('VLAN Translation Policy (name)'), + ) class Meta: model = VLANTranslationRule - fields = ('id', 'policy_id', 'local_vid', 'remote_vid', 'description') + fields = ('id', 'policy_id', 'policy', 'local_vid', 'remote_vid', 'description') def search(self, queryset, name, value): if not value.strip(): diff --git a/netbox/ipam/tests/test_filtersets.py b/netbox/ipam/tests/test_filtersets.py index d6902a64f..4f873d045 100644 --- a/netbox/ipam/tests/test_filtersets.py +++ b/netbox/ipam/tests/test_filtersets.py @@ -1976,6 +1976,11 @@ class VLANTranslationRuleTestCase(TestCase, ChangeLoggedFilterSetTests): params = {'policy_id': [policies[0].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) + def test_policy(self): + policies = VLANTranslationPolicy.objects.all()[:2] + params = {'policy': [policies[0].name]} + self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) + def test_local_vid(self): params = {'local_vid': [100]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)