From c76a5d237679e707b224b7867919a35e7347349d Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Tue, 1 Jan 2019 16:11:02 +0100 Subject: [PATCH] Prevents from crashing where there is no defined prefix_v6 --- machines/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/machines/models.py b/machines/models.py index 888e4ac0..1cf840d7 100644 --- a/machines/models.py +++ b/machines/models.py @@ -1380,7 +1380,10 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): .filter(interface=self.interface, slaac_ip=True) .exclude(id=self.id)): raise ValidationError(_("A SLAAC IP address is already registered.")) - prefix_v6 = self.interface.type.ip_type.prefix_v6.encode().decode('utf-8') + try: + prefix_v6 = self.interface.type.ip_type.prefix_v6.encode().decode('utf-8') + except AttributeError: # Prevents from crashing when there is no defined prefix_v6 + prefix_v6 = None if prefix_v6: if (IPv6Address(self.ipv6.encode().decode('utf-8')).exploded[:20] != IPv6Address(prefix_v6).exploded[:20]):