Skip to content

Commit

Permalink
Fixes #18392: Exclude config contexts assigned to locations for VMs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Jan 17, 2025
1 parent 4a13664 commit 879762f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netbox/extras/querysets.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ def _get_config_context_filters(self):
is_active=True,
)

# Apply Location & DeviceType filters only for VirtualMachines
if self.model._meta.model_name == 'device':
base_query.add((Q(locations=OuterRef('location')) | Q(locations=None)), Q.AND)
base_query.add((Q(device_types=OuterRef('device_type')) | Q(device_types=None)), Q.AND)

elif self.model._meta.model_name == 'virtualmachine':
base_query.add(Q(locations=None), Q.AND)
base_query.add(Q(device_types=None), Q.AND)

base_query.add((Q(roles=OuterRef('role')) | Q(roles=None)), Q.AND)
Expand Down

0 comments on commit 879762f

Please sign in to comment.