quas
quas

Reputation: 343

Django form error messages keys

I need to override default form for error messages and the way I am doing it is like below:

default_error_list = {
  'required': 'error message 1',
  'invalid': 'error message 2'
}
class JoinForm(forms.Form):
  username = forms.CharField(error_messages=default_error_list)

Can someone tell me where I can find all possible keys of errors: (required, invalid, etc.)

Upvotes: 5

Views: 1713

Answers (1)

Rafael
Rafael

Reputation: 7242

In the official Django documentation for the built-in fields there is a section exactly for what you are asking here

For your above example is:

CharField

  • required
  • max_length
  • min_length

Upvotes: 3

Related Questions