﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13693	error_messages for fields in Model don't carry over to ModelForm	Aleksandar Micovic	anonymous	"When having the optional error_messages parameter added to a field for some model, the errors don't get carried over to a ModelForm using that Model. For example:

MODEL:


{{{
class Contact(models.Model):

    ...

    first_name = models.CharField(max_length=30, verbose_name=u""first name"", error_messages={'required':'A contact needs a first name.'})
    
    ...

}}}


FORM:


{{{
class ContactQuickAddForm(ModelForm):
    class Meta:
        model = Contact
        fields = [""first_name"" ... ]

}}}

When validating, the error message doesn't change and it's default is shown: ""this field is required."" 

A workaround (thanks to subsume on IRC) is to override your ModelForm's __init__.


{{{
    def __init__(self,*args,**kwargs):
         super(ContactQuickAddForm,self).__init__(*args,**kwargs)
         self.fields['first_name'].error_messages = {'required': 'FAS:DJFASKL:DJF'}
}}}"	New feature	closed	Forms	1.4	Normal	invalid	error_messages, forms, models		Accepted	1	1	1	1	0	0
