-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v2.10.6
Python version
3.8
Steps to Reproduce
- Create a device named test-vc-1-1
- Create a device named test-vc-1-2
- Create a virtual chassis named test-vc-1 and bundle the two device created in 1. and 2.
- In the virtual chassis view perform a search by name using test-vc-1
Expected Behavior
The list view should display only one entry for the virtual chassis (check the screenshot of the search using Nebox 2.9 release)
Observed Behavior
The list view displays twice the same entry for the virtual chassis, one per member (check the screenshot of the search using Nebox 2.10.6 release)
Expected behaviour in netbox 2.9
Observed behaviour in netbox 2.10
Solution hint
After some code investigation it seems that the VirtualChassisFilterSet.search method in dcim/filter.py has something wrong with the forged queryset.
def search(self, queryset, name, value):
if not value.strip():
return queryset
qs_filter = (
Q(name__icontains=value) |
Q(members__name__icontains=value) |
Q(domain__icontains=value)
)
return queryset.filter(qs_filter)When you modify the queryset with the following code, the entry is not duplicated anymore in the WebUI.
def search(self, queryset, name, value):
if not value.strip():
return queryset
qs_filter = (
Q(name__icontains=value) |
Q(members__name__icontains=value) |
Q(domain__icontains=value)
)
return queryset.filter(qs_filter).distinct() # adding distinct de-duplicate the VCjmanteau, thomas-rotszyld and phurrelmann
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application

