diff options
| author | Tim Heap <tim@timheap.me> | 2017-03-10 10:45:50 +1100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-05-27 09:19:42 -0400 |
| commit | 5b6181f4d58f63e7d2b52ab94e162e5ce8980f12 (patch) | |
| tree | 326c51473d07cec66b947927039d347d28fbfe0b /docs | |
| parent | 2f09a285582cb475a9d27067808d9beefa7f9fba (diff) | |
Fixed #27922 -- Added ErrorDict.get_json_data().
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/api.txt | 11 | ||||
| -rw-r--r-- | docs/releases/2.0.txt | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index fda7472105..72ae044090 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -165,6 +165,17 @@ If for some reason you don't want to use client-side escaping, you can also set ``escape_html=True`` and error messages will be escaped so you can use them directly in HTML. +.. method:: Form.errors.get_json_data(escape_html=False) + +.. versionadded:: 2.0 + +Returns the errors as a dictionary suitable for serializing to JSON. +:meth:`Form.errors.as_json()` returns serialized JSON, while this returns the +error data before it's serialized. + +The ``escape_html`` parameter behaves as described in +:meth:`Form.errors.as_json()`. + .. method:: Form.add_error(field, error) This method allows adding errors to specific fields from within the diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index ee9ae181b4..e4b7110560 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -166,6 +166,10 @@ Forms HTML attributes for the ``DateInput`` and ``TimeInput`` (or hidden) subwidgets. +* The new :meth:`Form.errors.get_json_data() + <django.forms.Form.errors.get_json_data>` method returns form errors as + a dictionary suitable for including in a JSON response. + Generic Views ~~~~~~~~~~~~~ |
