pq.
pq.

Reputation: 3505

Django form field errors in templates

Django templates allow access to field errors via field.errors.as_ul. In Python, however, field has no attribute errors. How does this work?

My particular problem is that I tried serializing the forms (and the errors) and on the deserialization everything works in python, but errors don't show up if I ask explicitly for them via field.errors.as_ul. They do show up via field.errors, though: basically, the list of strings shows.

Can someone explain this?

Upvotes: 0

Views: 1039

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599628

There are actually two separate classes for fields - the field elements you declare in your form, and a BoundField class which is automatically created by the form and which contains any bound data and errors.

Upvotes: 1

Related Questions