I can see how to add an error message to a field when using forms, but what about model form?
This is my test model:
class Author(models.Model):
the easyest way is to override the clean method:
class AuthorForm(forms.ModelForm): class Meta: model = Author def clean(self): if self.cleaned_data.get('name')=="": raise forms.ValidationError('No name!') return self.cleaned_data