1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix VLAN.clean()

This commit is contained in:
Jeremy Stretch
2021-03-10 16:26:27 -05:00
parent f4e49495e2
commit d3fee54644

View File

@@ -173,10 +173,11 @@ class VLAN(PrimaryModel):
def clean(self):
super().clean()
# Validate VLAN group
if self.group and self.group.site != self.site:
# Validate VLAN group (if assigned)
if self.group and self.site and self.group.scope != self.site:
raise ValidationError({
'group': "VLAN group must belong to the assigned site ({}).".format(self.site)
'group': f"VLAN is assigned to group {self.group} (scope: {self.group.scope}); cannot also assign to "
f"site {self.site}."
})
def to_csv(self):