I have a problem with form errors. I want to change the field name that the form error displays.
models.py
class Sales(models.Model):
customer = models.ForeignKey("Customer")
ctype = models.ForeignKey("Customer_type", verbose_name="Customer Type")
forms.py
from django.utils.translation import ugettext_lazy as _
class Sales_form(forms.ModelForm):
class Meta:
model = Sales
fields = ('customer','ctype')
error_messages = {
'ctype' : {
'required' : _("Hey yow! this field is required!")
}
}
but the error still returns:
{"ctype": ["Hey yow! this field is required!"]}
What I want is like this
{"Customer Type": ["Hey yow! this field is required!"]}