1👍
Ok so a little more explanation and a couple links that might help shed some light on this. In the official Django documentation (https://docs.djangoproject.com/en/1.10/ref/forms/fields/) there is an example of using form field validation with custom error messages. The error_messages
must be defined within the field you want the error message associated with:
text = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}), error_messages = { 'required': TEXT_EMPTY_ERROR})
That being said, another Django documentation (https://docs.djangoproject.com/en/1.10/topics/forms/modelforms/) shows creating custom error_messages in the Meta class for a Model form. Since the first line is working that’s great, but I think if you wanted to create error messages in the manner you originally posted, you might try following the documentation. Under the “Overriding Default Fields section in the docs they show an example very similar to what you are doing so that should give you an idea of maybe what went wrong. I believe it’s a combination of using these []
instead of these ()
to wrap your fields and then not overriding the field in the Meta class itself. Hopefully this gives a bit of insight into Django and testing though!!