From fb6a522614a4d3960928d73d794d367af2233109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Tue, 19 Sep 2017 20:09:12 +0000 Subject: [PATCH] Filtre les mac illisibles, non valide et None --- machines/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/machines/models.py b/machines/models.py index 7f86d0c0..8eff89fc 100644 --- a/machines/models.py +++ b/machines/models.py @@ -235,10 +235,9 @@ class Interface(models.Model): return str(EUI(self.mac_address, dialect=mac_bare)).lower() def filter_macaddress(self): - mac_address = str(EUI(self.mac_address)) - if mac_address: - self.mac_address = mac_address - else: + try: + self.mac_address = str(EUI(self.mac_address)) + except : raise ValidationError("La mac donnée est invalide") def clean(self, *args, **kwargs):