#10172 fixes for Django 4.1

This commit is contained in:
Arthur 2022-09-12 09:59:37 -07:00
parent 27d72746ca
commit ce6bf9e5c1
3 changed files with 9 additions and 8 deletions

View File

@ -953,6 +953,7 @@ class RearPort(ModularComponentModel, CabledObjectModel):
super().clean() super().clean()
# Check that positions count is greater than or equal to the number of associated FrontPorts # Check that positions count is greater than or equal to the number of associated FrontPorts
if self.pk:
frontport_count = self.frontports.count() frontport_count = self.frontports.count()
if self.positions < frontport_count: if self.positions < frontport_count:
raise ValidationError({ raise ValidationError({

View File

@ -268,7 +268,7 @@ class DeviceType(NetBoxModel):
if ( if (
self.subdevice_role != SubdeviceRoleChoices.ROLE_PARENT self.subdevice_role != SubdeviceRoleChoices.ROLE_PARENT
) and self.devicebaytemplates.count(): ) and self.pk and self.devicebaytemplates.count():
raise ValidationError({ raise ValidationError({
'subdevice_role': "Must delete all device bay templates associated with this device before " 'subdevice_role': "Must delete all device bay templates associated with this device before "
"declassifying it as a parent device." "declassifying it as a parent device."

View File

@ -367,7 +367,7 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
}) })
# Validate primary IP addresses # Validate primary IP addresses
interfaces = self.interfaces.all() interfaces = self.interfaces.all() if self.pk else None
for family in (4, 6): for family in (4, 6):
field = f'primary_ip{family}' field = f'primary_ip{family}'
ip = getattr(self, field) ip = getattr(self, field)