Skip to content

Commit

Permalink
Add missing object_id filter to TaggedItemFilterSet
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 25, 2025
1 parent 3894e2c commit bf48e5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion netbox/extras/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class TaggedItemFilterSet(BaseFilterSet):

class Meta:
model = TaggedItem
fields = ('id',)
fields = ('id', 'object_id')

def search(self, queryset, name, value):
if not value.strip():
Expand Down
8 changes: 8 additions & 0 deletions netbox/extras/tests/test_filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,14 @@ def test_object_type(self):
params = {'object_type_id': [object_type.pk]}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3)

def test_object_id(self):
site_ids = Site.objects.values_list('pk', flat=True)
params = {
'object_type': 'dcim.site',
'object_id': site_ids[:2],
}
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)


class ChangeLoggedFilterSetTestCase(TestCase):
"""
Expand Down

0 comments on commit bf48e5b

Please sign in to comment.