Django: Get the error messages of a form field
Is it possible to the error messages of a form field? I did some digging a开发者_如何学JAVAnd the field has a property error_messages which is a dictionary but the values return:
<django.utils.functional.__proxy__ object at 0x2591d50>
So was wondering how I can get the error message from that? I am trying to add metadata to the data-validate attribute of the field's widget so I can use client side validation.
It seems a translated string. To get the text, just use unicode
on it:
unicode(error_message)
精彩评论