I want to know in my view, if a certain field raised an error, that way I can send some values to the template (index of current tab (using a javascript tab widget)). Is it possible?
Thanks in advance.
You can definitely access your form errors in your view. Each bound Form instance has an errors attribute that gives you a dictionary mapping field name to error-message lists:
>>> f = ContactForm({'subject': 'Hello', 'message':''})
>>> f.errors
{'message':[u'This field is required.']}
You can access individual fields as follows:
>>> if f['subject'].errors:
values = [Add values to send to template]
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