mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Template system now supports variables whose str() returns a Unicode object with non-ascii characters. Thanks, gabor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4161 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -742,7 +742,11 @@ class VariableNode(Node):
|
||||
def encode_output(self, output):
|
||||
# Check type so that we don't run str() on a Unicode object
|
||||
if not isinstance(output, basestring):
|
||||
return str(output)
|
||||
try:
|
||||
return str(output)
|
||||
except UnicodeEncodeError:
|
||||
# If __str__() returns a Unicode object, convert it to bytestring.
|
||||
return unicode(output).encode(settings.DEFAULT_CHARSET)
|
||||
elif isinstance(output, unicode):
|
||||
return output.encode(settings.DEFAULT_CHARSET)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user