From 4a685bc0dca5298a7d5a4e162120a90cac7fd1a4 Mon Sep 17 00:00:00 2001 From: SaJH Date: Wed, 11 Sep 2024 21:23:23 +0900 Subject: Fixed #35727 -- Added HttpResponse.text property. Signed-off-by: SaJH --- docs/ref/request-response.txt | 10 ++++++++++ docs/releases/5.2.txt | 3 +++ 2 files changed, 13 insertions(+) (limited to 'docs') diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index 31111a435a..afebd00d8b 100644 --- a/docs/ref/request-response.txt +++ b/docs/ref/request-response.txt @@ -833,6 +833,13 @@ Attributes A bytestring representing the content, encoded from a string if necessary. +.. attribute:: HttpResponse.text + + .. versionadded:: 5.2 + + A string representation of :attr:`HttpResponse.content`, decoded using the + response's :attr:`HttpResponse.charset` (defaulting to ``UTF-8`` if empty). + .. attribute:: HttpResponse.cookies A :py:obj:`http.cookies.SimpleCookie` object holding the cookies included @@ -1272,6 +1279,9 @@ with the following notable differences: :attr:`~StreamingHttpResponse.streaming_content` attribute. This can be used in middleware to wrap the response iterable, but should not be consumed. +* It has no ``text`` attribute, as it would require iterating the response + object. + * You cannot use the file-like object ``tell()`` or ``write()`` methods. Doing so will raise an exception. diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index 806abfa26d..9090f8b70a 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -268,6 +268,9 @@ Models Requests and Responses ~~~~~~~~~~~~~~~~~~~~~~ +* The new :attr:`.HttpResponse.text` property provides the string representation + of :attr:`.HttpResponse.content`. + * The new :meth:`.HttpRequest.get_preferred_type` method can be used to query the preferred media type the client accepts. -- cgit v1.3