mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #27922 -- Added ErrorDict.get_json_data().
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user