#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 |
Description
The documentation for Form.errors (http://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.errors) says that Form.errors will return a python dict. Instead an html unordered list is returned.
Attachments (1)
Change History (4)
by , 15 years ago
Attachment: | contactform_errors.py added |
---|
comment:1 by , 15 years ago
Cc: | added |
---|
follow-up: 3 comment:2 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Your test prints the errors. This causes the errors dict to get converted to an HTML unordered list. See:
http://code.djangoproject.com/browser/django/tags/releases/1.1/django/forms/util.py#L14
If you access it directly instead of printing it, you will see it is a dict:
>>> import django >>> django.get_version() '1.1' >>> from django import forms >>> class SForm(forms.Form): ... int = forms.IntegerField() ... >>> sf = SForm({}) >>> sf.is_valid() False >>> 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> >>>
Note:
See TracTickets
for help on using tickets.
Simple test that prints out the errors of an invalid form