forms.py
class MyForm(forms.Form):
no = forms.CharField(error_messages={'required': u'must be xxx')
template.html
{{form.no.error}}
{{form.no.error}}
is <ul class="errorlist"><li>must be xxx</li></ul>
I want to format {{form.no.error}}
to plain text message without any html tags
You could either just remove the tags:
{{ form.no.errors|striptags }}
Or just access the raw error:
{{ form.no.errors.as_text }}
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