1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2845: Enable filtering of rack unit list by unit ID

This commit is contained in:
Jeremy Stretch
2019-02-06 10:44:05 -05:00
parent 73c983516d
commit ca51fab4d8
2 changed files with 6 additions and 0 deletions

View File

@@ -159,6 +159,11 @@ class RackViewSet(CustomFieldModelViewSet):
exclude_pk = None
elevation = rack.get_rack_units(face, exclude_pk)
# Enable filtering rack units by ID
q = request.GET.get('q', None)
if q:
elevation = [u for u in elevation if q in str(u['id'])]
page = self.paginate_queryset(elevation)
if page is not None:
rack_units = serializers.RackUnitSerializer(page, many=True, context={'request': request})