aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils/__init__.py
diff options
context:
space:
mode:
authorTom Christie2013-02-06 00:53:41 -0800
committerTom Christie2013-02-06 00:53:41 -0800
commit72fe686623f63b79fa2b7f7de177c6d98bc1da3f (patch)
tree5d0834d4eb2caf21ed54a4dcba9a4a3a40e6fa99 /rest_framework/utils/__init__.py
parent221e77d3575c182eb49d50546f844f392a5f7ba6 (diff)
parentbdc97c561147130b59c8cd8cc6bc735eab8b223d (diff)
downloaddjango-rest-framework-72fe686623f63b79fa2b7f7de177c6d98bc1da3f.tar.bz2
Merge pull request #636 from tomchristie/2.2
2.2 Release
Diffstat (limited to 'rest_framework/utils/__init__.py')
-rw-r--r--rest_framework/utils/__init__.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/rest_framework/utils/__init__.py b/rest_framework/utils/__init__.py
index 84fcb5db..3bab3b5f 100644
--- a/rest_framework/utils/__init__.py
+++ b/rest_framework/utils/__init__.py
@@ -1,6 +1,8 @@
-from django.utils.encoding import smart_unicode
+from __future__ import unicode_literals
from django.utils.xmlutils import SimplerXMLGenerator
from rest_framework.compat import StringIO
+from rest_framework.compat import six
+from rest_framework.compat import smart_text
import re
import xml.etree.ElementTree as ET
@@ -70,7 +72,7 @@ class XMLRenderer():
xml.endElement("list-item")
elif isinstance(data, dict):
- for key, value in data.iteritems():
+ for key, value in six.iteritems(data):
xml.startElement(key, {})
self._to_xml(xml, value)
xml.endElement(key)
@@ -80,10 +82,10 @@ class XMLRenderer():
pass
else:
- xml.characters(smart_unicode(data))
+ xml.characters(smart_text(data))
def dict2xml(self, data):
- stream = StringIO.StringIO()
+ stream = StringIO()
xml = SimplerXMLGenerator(stream, "utf-8")
xml.startDocument()