I understand form the documentation http://docs.djangoproject.com/en/dev/ref/models/fields/ that you can add error_messages to a model field and supply your own dict of error messages. However, what are they keys of the dict you are supposed to pass?

class MyModel(models.Model):
   some_field = models.CharField(max_length=55, error_messages={'required': "My custom error"})

If it is easier to do this on the modelform that is used that would also work, however. I would rather not have to create explicitly creating each field and their type again. This is what I was trying to avoid:

class MyModelForm(forms.ModelForm):
    some_field = forms.CharField(error_messages={'required' : 'Required error'})

Update 2: Test code used in my project

My Model:

class MyTestModel(models.Model):
    name = models.CharField(max_length=127,error_messages={'blank' : 'BLANK','required' : 'REQUIRED'})

My Form:

class EditTestModel(ModelForm):
    class Meta:
        model = MyTestModel

My View:

tf = EditTestModel({'name' : ''})

print tf.is_valid() # prints False
print tf.full_clean() # prints None
print tf # prints the form, with a <li> error list containg the error "This field is required"


<tr><th><label for="id_name">Name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input id="id_name" type="text" name="name" maxlength="127" /></td></tr>
Edit
Report