Description
Deployment Type
Self-hosted
NetBox Version
v4.0.10
Python Version
3.11
Steps to Reproduce
1 Use the data from https://github.com/netbox-community/netbox-demo-data
2 Add prefix in VRF shared
3 Use ipam/prefixes/?present_in_vrf_id=5 (echo VRF) to have all prefixes from Shared and Echo VRF
Expected Behavior
A display of all prefixes seen from Echo VRF point of view
Observed Behavior
All prefixes from Echo VRF are displayed twice
It seems the union of querysets returns twice the value of the VRF in parameter :
netbox/netbox/ipam/filtersets.py
Line 455 in 886d635
tested into nbshell itself :
echo=VRF.objects.get(id=5)
queryset=VRF.objects.all()
queryset.filter(Q(id=5))
<RestrictedQuerySet [<VRF: Echo (65000:500)>]>
queryset.filter(Q(export_targets__in=echo.import_targets.all()))
<RestrictedQuerySet [<VRF: Shared (65000:1)>]>
queryset.filter(Q(id=5) |Q(export_targets__in=echo.import_targets.all()))
<RestrictedQuerySet [<VRF: Echo (65000:500)>, <VRF: Echo (65000:500)>, <VRF: Shared (65000:1)>]>
I found a kind of explanation on stackoverflow : https://stackoverflow.com/questions/4411049/how-can-i-find-the-union-of-two-django-querysets
Would the .distinct() method answer my issue?