views:

616

answers:

1

If I look in Django's forms.py, as_p() calls _html_output(), which styles field errors with self.error_class() (although I can't locate the definition of that).

However, _html_output() does NOT style non_field_errors (a.k.a. top_errors in the code).

How does one style the non-field errors? Cut and paste all of _html_output?

I am using Django 1.0.

+3  A: 

In your template you can access {{ form.non_field_errors }} and render them however you like. Here's how the Django admin handles them for example: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/admin/change%5Fform.html#L40

Alex Gaynor
Thanks. Sad to recreate all the form rendering code in template language, but maybe that is the right thing. Do you know of a ref to the full template equivalent of as_p? http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-hidden-and-visible-fields is close, but probably not the same.
dfrankow