[Answered ]-Show the custom message in Django form

2👍

You can try setting the custom message in the __init__() like so:

class ArticleForm(ModelForm):
    title = forms.CharField(max_length=128, 
                            required=True,
                            widget=forms.TextInput(attrs={'size': 60}))
    class Meta:
        model  = Article
        fields = ["title"]

    def __init__(self, *args, **kwargs):
        super(ArticleForm, self).__init__(*args, **kwargs)

        # add custom error messages
        self.fields['title'].error_messages['required'] = 'Please enter title'
👤jape

Leave a comment