In Django, how do i change "This field is required." to "Name is required"?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Secret Catacombs
--
Chapters
00:00 Question
00:37 Accepted answer (Score 23)
01:08 Answer 2 (Score 0)
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/4466...
Accepted answer links:
http://docs.djangoproject.com/en/dev/ref...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #forms #frameworks
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Secret Catacombs
--
Chapters
00:00 Question
00:37 Accepted answer (Score 23)
01:08 Answer 2 (Score 0)
01:31 Thank you
--
Full question
https://stackoverflow.com/questions/4466...
Accepted answer links:
http://docs.djangoproject.com/en/dev/ref...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #forms #frameworks
#avk47
ACCEPTED ANSWER
Score 23
An easy way to specify simple "required" validation messages is to pass the field the error_messages argument.
name = forms.CharField(error_messages={'required': 'Your Name is Required'}) 
Check the docs for which keys can be specified per field: http://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.Field.error_messages
For anything else, you're going to need real form validation which means you'd be writing error messages anyways!
ANSWER 2
Score 0
If you want to customize the message a little bit more you can also:
from django.core.exceptions import ValidationError
def my_validator(value):
    if not len(value):
        raise ValidationError('Your error message here!')
Then, in your models.py:
from django import forms
class MyForm(forms.Form):
    my_field= forms.CharField(validators=[my_validator])