Return unicode from template's render

97 views
Skip to first unread message

Ivan Sagalaev

unread,
Jun 17, 2007, 4:15:17 AM6/17/07
to django-d...@googlegroups.com
Hello everyone (and Malcolm especially)!

This is about template rendering in unicode branch. Template's render
now returns a byte string encoded in a DEFAULT_CHARSET. However just
yesterday I've come across a case where a developer needed to render a
template not to send it over HTTP connection but for some internal
usage. It was then concatenated to some other unicode strings and failed
with UnicodeDecodeError doing implicit unicode(). Then it striked me
that we encode rendered output just for sending it over a wire and it
should be handled in HttpResponse and send_email. In fact HttpResponse
already encodes unicode objects using DEFAULT_CHARSET. Not sure about
email machinery.

Malcolm Tredinnick

unread,
Jun 17, 2007, 4:26:29 AM6/17/07
to django-d...@googlegroups.com

That sounds reasonable.

Malcolm


Ivan Sagalaev

unread,
Jun 18, 2007, 4:31:32 AM6/18/07
to django-d...@googlegroups.com
Malcolm Tredinnick wrote:
> That sounds reasonable.

Just was about to make a patch but saw your changeset implementing it.
Thanks!

Reply all
Reply to author
Forward
0 new messages