1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Added JSON Parser and request.data

This commit is contained in:
David Smith
2023-12-04 17:20:38 +00:00
parent 31aabb20c2
commit 32ea23f53b
9 changed files with 319 additions and 53 deletions

View File

@@ -57,6 +57,16 @@ Parses HTML form content (). The ``parse()`` method returns a
Parses multipart form content and supports file uploads. The method returns
a ``QueryDict`` for ``data`` and an ``MultiValueDict`` for ``FILES``.
.. class:: JSONParser
.. attribute:: media_type
``"application/json"``
The ``parse()`` method deserializes JSON to a Python dictionary. This is
returned for ``data`` and empty ``MultiValueDict`` is provided for ``FILES``.
HttpRequest.Parsers
===================

View File

@@ -119,6 +119,15 @@ All attributes should be considered read-only, unless stated otherwise.
``POST`` does *not* include file-upload information. See :attr:`FILES`.
.. attribute:: HttpRequest.data
Similar to :attr:`HttpRequest.POST` but parses the :attr:`HttpRequest.body`
with the parsers returned by :attr:`HttpRequest.parsers``. By default this
will result in ``application/json`` data being parsed in addition to form
data.
In addition data will be parsed for all :attr:`HttpRequest.method` methods.
.. attribute:: HttpRequest.COOKIES
A dictionary containing all cookies. Keys and values are strings.