diff --git a/djangocms_alias/forms.py b/djangocms_alias/forms.py index cc4eb653..20ed212e 100644 --- a/djangocms_alias/forms.py +++ b/djangocms_alias/forms.py @@ -323,10 +323,14 @@ class Meta: def clean(self): cleaned_data = super().clean() + alias = cleaned_data.get('alias') + if not alias: + return cleaned_data + if AliasContent.objects.filter( name=cleaned_data.get('name'), language=cleaned_data.get('language'), - alias__category=cleaned_data.get('alias').category, + alias__category=alias.category, ).exists(): raise forms.ValidationError( _('Alias with this Name and Category already exists.')