mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #10190 -- Made HttpResponse charset customizable.
Thanks to Simon Charette, Aymeric Augustin, and Tim Graham for reviews and contributions.
This commit is contained in:
parent
9d6551204e
commit
5f2542f12a
7 changed files with 125 additions and 18 deletions
|
@ -627,6 +627,15 @@ Attributes
|
|||
A bytestring representing the content, encoded from a Unicode
|
||||
object if necessary.
|
||||
|
||||
.. attribute:: HttpResponse.charset
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
A string denoting the charset in which the response will be encoded. If not
|
||||
given at ``HttpResponse`` instantiation time, it will be extracted from
|
||||
``content_type`` and if that is unsuccessful, the
|
||||
:setting:`DEFAULT_CHARSET` setting will be used.
|
||||
|
||||
.. attribute:: HttpResponse.status_code
|
||||
|
||||
The `HTTP status code`_ for the response.
|
||||
|
@ -645,7 +654,7 @@ Attributes
|
|||
Methods
|
||||
-------
|
||||
|
||||
.. method:: HttpResponse.__init__(content='', content_type=None, status=200, reason=None)
|
||||
.. method:: HttpResponse.__init__(content='', content_type=None, status=200, reason=None, charset=None)
|
||||
|
||||
Instantiates an ``HttpResponse`` object with the given page content and
|
||||
content type.
|
||||
|
@ -666,6 +675,14 @@ Methods
|
|||
``reason`` is the HTTP response phrase. If not provided, a default phrase
|
||||
will be used.
|
||||
|
||||
``charset`` is the charset in which the response will be encoded. If not
|
||||
given it will be extracted from ``content_type``, and if that
|
||||
is unsuccessful, the :setting:`DEFAULT_CHARSET` setting will be used.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
The ``charset`` parameter was added.
|
||||
|
||||
.. method:: HttpResponse.__setitem__(header, value)
|
||||
|
||||
Sets the given header name to the given value. Both ``header`` and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue