From 47b69a9ea70079a264374ba9807aad698d5250bd Mon Sep 17 00:00:00 2001 From: Toralf Neby berge Date: Sat, 10 Mar 2018 15:52:40 +0100 Subject: [PATCH] Remove unnecessary if statement --- mdb/forms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mdb/forms.py b/mdb/forms.py index 5d2b5cd..de454c4 100644 --- a/mdb/forms.py +++ b/mdb/forms.py @@ -20,11 +20,10 @@ class InterfaceForm(forms.ModelForm): macaddr = self.cleaned_data['macaddr'] ip4address = self.cleaned_data['ip4address'] - if Interface.objects.filter(macaddr=macaddr).exists(): - for interface in Interface.objects.filter(macaddr=macaddr): - subnet = interface.ip4address.subnet - if subnet == ip4address.subnet and interface != self.instance: - raise ValidationError('Macaddr already in this subnet') + for interface in Interface.objects.filter(macaddr=macaddr): + subnet = interface.ip4address.subnet + if subnet == ip4address.subnet and interface != self.instance: + raise ValidationError('Macaddr already in this subnet') def __init__(self, *args, **kwargs): super(InterfaceForm, self).__init__(*args, **kwargs)