From 6ecbf45974807563b76d40377e4b453b909933da Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 29 Jun 2020 11:48:36 -0400 Subject: [PATCH] Fix evaluation of RestrictedQuerySets --- netbox/virtualization/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/virtualization/models.py b/netbox/virtualization/models.py index 4a753561a..5d74f8468 100644 --- a/netbox/virtualization/models.py +++ b/netbox/virtualization/models.py @@ -176,7 +176,7 @@ class Cluster(ChangeLoggedModel, CustomFieldModel): # If the Cluster is assigned to a Site, verify that all host Devices belong to that Site. if self.pk and self.site: - nonsite_devices = Device.objects.filter(cluster=self).exclude(site=self.site).count() + nonsite_devices = Device.objects.unrestricted().filter(cluster=self).exclude(site=self.site).count() if nonsite_devices: raise ValidationError({ 'site': "{} devices are assigned as hosts for this cluster but are not in site {}".format( @@ -316,7 +316,7 @@ class VirtualMachine(ChangeLoggedModel, ConfigContextModel, CustomFieldModel): # Check for a duplicate name on a VM assigned to the same Cluster and no Tenant. This is necessary # because Django does not consider two NULL fields to be equal, and thus will not trigger a violation # of the uniqueness constraint without manual intervention. - if self.tenant is None and VirtualMachine.objects.exclude(pk=self.pk).filter( + if self.tenant is None and VirtualMachine.objects.unrestricted().exclude(pk=self.pk).filter( name=self.name, tenant__isnull=True ): raise ValidationError({