summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.5.txt22
-rw-r--r--docs/topics/testing.txt57
2 files changed, 55 insertions, 24 deletions
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index 46b599a622..851fed69f7 100644
--- a/docs/releases/1.5.txt
+++ b/docs/releases/1.5.txt
@@ -56,7 +56,7 @@ previously loaded. For example, with the tutorial's models::
True
In Django 1.5, the third line no longer triggers a new SQL query to fetch
-``first_choice.poll``; it was set when by the second line.
+``first_choice.poll``; it was set by the second line.
For one-to-one relationships, both sides can be cached. For many-to-one
relationships, only the single side of the relationship can be cached. This
@@ -101,6 +101,26 @@ year|date:"Y" }}``.
``next_year`` and ``previous_year`` were also added in the context. They are
calculated according to ``allow_empty`` and ``allow_future``.
+OPTIONS, PUT and DELETE requests in the test client
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Unlike GET and POST, these HTTP methods aren't implemented by web browsers.
+Rather, they're used in APIs, which transfer data in various formats such as
+JSON or XML. Since such requests may contain arbitrary data, Django doesn't
+attempt to decode their body.
+
+However, the test client used to build a query string for OPTIONS and DELETE
+requests like for GET, and a request body for PUT requests like for POST. This
+encoding was arbitrary and inconsistent with Django's behavior when it
+receives the requests, so it was removed in Django 1.5.
+
+If you were using the ``data`` parameter in an OPTIONS or a DELETE request,
+you must convert it to a query string and append it to the ``path`` parameter.
+
+If you were using the ``data`` parameter in a PUT request without a
+``content_type``, you must encode your data before passing it to the test
+client and set the ``content_type`` argument.
+
Features deprecated in 1.5
==========================
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index d5ccc2d8fc..f35c545c30 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -805,45 +805,56 @@ arguments at time of construction:
.. method:: Client.head(path, data={}, follow=False, **extra)
- Makes a HEAD request on the provided ``path`` and returns a ``Response``
- object. Useful for testing RESTful interfaces. Acts just like
- :meth:`Client.get` except it does not return a message body.
+ Makes a HEAD request on the provided ``path`` and returns a
+ ``Response`` object. This method works just like :meth:`Client.get`,
+ including the ``follow`` and ``extra`` arguments, except it does not
+ return a message body.
- If you set ``follow`` to ``True`` the client will follow any redirects
- and a ``redirect_chain`` attribute will be set in the response object
- containing tuples of the intermediate urls and status codes.
-
- .. method:: Client.options(path, data={}, follow=False, **extra)
+ .. method:: Client.options(path, data='', content_type='application/octet-stream', follow=False, **extra)
Makes an OPTIONS request on the provided ``path`` and returns a
``Response`` object. Useful for testing RESTful interfaces.
- If you set ``follow`` to ``True`` the client will follow any redirects
- and a ``redirect_chain`` attribute will be set in the response object
- containing tuples of the intermediate urls and status codes.
+ When ``data`` is provided, it is used as the request body, and
+ a ``Content-Type`` header is set to ``content_type``.
- The ``extra`` argument acts the same as for :meth:`Client.get`.
+ .. versionchanged:: 1.5
+ :meth:`Client.options` used to process ``data`` like
+ :meth:`Client.get`.
+
+ The ``follow`` and ``extra`` arguments act the same as for
+ :meth:`Client.get`.
- .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)
+ .. method:: Client.put(path, data='', content_type='application/octet-stream', follow=False, **extra)
Makes a PUT request on the provided ``path`` and returns a
- ``Response`` object. Useful for testing RESTful interfaces. Acts just
- like :meth:`Client.post` except with the PUT request method.
+ ``Response`` object. Useful for testing RESTful interfaces.
- If you set ``follow`` to ``True`` the client will follow any redirects
- and a ``redirect_chain`` attribute will be set in the response object
- containing tuples of the intermediate urls and status codes.
+ When ``data`` is provided, it is used as the request body, and
+ a ``Content-Type`` header is set to ``content_type``.
+
+ .. versionchanged:: 1.5
+ :meth:`Client.put` used to process ``data`` like
+ :meth:`Client.post`.
- .. method:: Client.delete(path, follow=False, **extra)
+ The ``follow`` and ``extra`` arguments act the same as for
+ :meth:`Client.get`.
+
+ .. method:: Client.delete(path, data='', content_type='application/octet-stream', follow=False, **extra)
Makes an DELETE request on the provided ``path`` and returns a
``Response`` object. Useful for testing RESTful interfaces.
- If you set ``follow`` to ``True`` the client will follow any redirects
- and a ``redirect_chain`` attribute will be set in the response object
- containing tuples of the intermediate urls and status codes.
+ When ``data`` is provided, it is used as the request body, and
+ a ``Content-Type`` header is set to ``content_type``.
+
+ .. versionchanged:: 1.5
+ :meth:`Client.delete` used to process ``data`` like
+ :meth:`Client.get`.
+
+ The ``follow`` and ``extra`` arguments act the same as for
+ :meth:`Client.get`.
- The ``extra`` argument acts the same as for :meth:`Client.get`.
.. method:: Client.login(**credentials)