From 7ba850af3ba4ac7dbe3d67a2360079bce0bf0eb3 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 25 May 2007 09:48:02 +0000 Subject: unicode: Added a more convenient way to set/change the encoding on a request instance. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5342 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/unicode.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/unicode.txt b/docs/unicode.txt index 41df214387..01fff198c1 100644 --- a/docs/unicode.txt +++ b/docs/unicode.txt @@ -337,14 +337,17 @@ be returned exactly as they were submitted by the client. By default, the ``DEFAULT_CHARSET`` setting is used as the assumed encoding for form data. If you need to change this for a particular form, you can set the ``encoding`` attribute on the ``GET`` and ``POST`` data structures. For -example:: +convenience, changing the ``encoding`` property on an ``HttpRequest`` instance +does this for you. For example:: def some_view(request): # We know that the data must be encoded as KOI8-R (for some reason). - request.GET.encoding = 'koi8-r' - request.POST.encoding = 'koi8-r' + request.encoding = 'koi8-r' ... +You can even change the encoding after having accessed ``request.GET`` or +``request.POST`` and all subsequent accesses will use the new encoding. + It will typically be very rare that you would need to worry about changing the form encoding. However, if you are talking to a legacy system or a system beyond your control with particular ideas about encoding, you do have a way to -- cgit v1.3