49👍
✅
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['name'].error_messages = {'required': 'custom required message'}
# if you want to do it to all of them
for field in self.fields.values():
field.error_messages = {'required':'The field {fieldname} is required'.format(
fieldname=field.label)}
- [Django]-Images from ImageField in Django don't load in template
- [Django]-How does one make logging color in Django/Google App Engine?
- [Django]-Django: how to do calculation inside the template html page?
Source:stackexchange.com