Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#11958 closed (invalid)

Form.errors returns an HTML unordered list, rather than a python dict object

Reported by: brook Owned by: nobody
Component: Documentation Version: 1.1
Severity: Keywords: dict list form errors
Cc: bruscoob@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The documentation for Form.errors ( says that Form.errors will return a python dict. Instead an html unordered list is returned.

Attachments (1) (518 bytes) - added by brook 10 years ago.
Simple test that prints out the errors of an invalid form

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by brook

Attachment: added

Simple test that prints out the errors of an invalid form

comment:1 Changed 10 years ago by brook

Cc: bruscoob@… added

comment:2 Changed 10 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

Your test prints the errors. This causes the errors dict to get converted to an HTML unordered list. See:

If you access it directly instead of printing it, you will see it is a dict:

>>> import django
>>> django.get_version()
>>> from django import forms
>>> class SForm(forms.Form):
...    int = forms.IntegerField()
>>> sf = SForm({})
>>> sf.is_valid()
>>> sf.errors
{'int': [u'This field is required.']}
>>> print sf.errors
<ul class="errorlist"><li>int<ul class="errorlist"><li>This field is required.</li></ul></li></ul>

comment:3 in reply to:  2 Changed 10 years ago by brook

Gotcha - that makes sense.

Note: See TracTickets for help on using tickets.
Back to Top