From 879762fc1db5cab74a29dd86d33f367858b08f97 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 17 Jan 2025 12:20:24 -0500 Subject: [PATCH] Fixes #18392: Exclude config contexts assigned to locations for VMs --- netbox/extras/querysets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox/extras/querysets.py b/netbox/extras/querysets.py index 9b3722eef07..59be8573492 100644 --- a/netbox/extras/querysets.py +++ b/netbox/extras/querysets.py @@ -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)