Pickels
Pickels

Reputation: 34632

Django: Get the error messages of a form field

Is it possible to the error messages of a form field? I did some digging and 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.

Upvotes: 1

Views: 872

Answers (1)

Don
Don

Reputation: 17606

It seems a translated string. To get the text, just use unicode on it:

unicode(error_message)

Upvotes: 4

Related Questions