I would like to get on my template the errors of the form in non-html version.
by default the error is wrap up by <ul class="errorlist">
which I want to avoid.
Anyway to do it without a massive code change ?
There are two new methods in Django 1.7 that would also be useful to solve this problem:
Form.errors.as_data()
>>> f.errors.as_data()
{'sender': [ValidationError(['Enter a valid email address.'])],
'subject': [ValidationError(['This field is required.'])]}
Form.errors.as_json()
>>> f.errors.as_json()
{"sender": [{"message": "Enter a valid email address.", "code": "invalid"}],
"subject": [{"message": "This field is required.", "code": "required"}]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With