diff --git a/webapp/forms.py b/webapp/forms.py index d5c7067..7a28867 100644 --- a/webapp/forms.py +++ b/webapp/forms.py @@ -43,7 +43,7 @@ class KaehmyForm_Form(forms.ModelForm): def clean_custom_role_name(self): """Check that no other custom role with same name exists.""" custom_name = self.cleaned_data.get('custom_role_name') - if CustomKaehmyRole.objects.get(name=custom_name) is None: + if not CustomKaehmyRole.objects.filter(name=custom_name).exists(): return custom_name else: raise ValidationError(_('Custom role with the same name already exists.'))