Fix kaehmy form error

This commit is contained in:
Jan Tuomi
2017-10-16 12:43:27 +03:00
parent c5ad46c411
commit 44c6422c41
+1 -1
View File
@@ -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.'))