How can I add a custom error message in a Django form?
For example, I want to add a new error message in a view if two e-mails aren’t the same.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First you must define a function that begins with clean_[your field name] — for example: def clean_email. Then write your validation in your function and assign an error name and use it in error_messages of your field.