diff --git a/requirements.txt b/requirements.txt index 96f0a23..6083d1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ wheel==0.24.0 # MkDocs for documentation previews/deploys mkdocs==0.11.1 +six==1.14.0 diff --git a/rest_framework_yaml/compat.py b/rest_framework_yaml/compat.py index 9f6c147..9ab839a 100644 --- a/rest_framework_yaml/compat.py +++ b/rest_framework_yaml/compat.py @@ -3,8 +3,7 @@ versions of django/python, and compatibility wrappers around optional packages. """ # flake8: noqa - -from django.utils import six +import six try: import yaml except ImportError: diff --git a/rest_framework_yaml/encoders.py b/rest_framework_yaml/encoders.py index a69dc70..9d80e52 100644 --- a/rest_framework_yaml/encoders.py +++ b/rest_framework_yaml/encoders.py @@ -5,8 +5,8 @@ import decimal import types -from django.utils import six - +import six +from uuid import UUID from .compat import ( yaml, yaml_represent_text, Hyperlink, OrderedDict, ReturnDict, ReturnList ) @@ -34,8 +34,12 @@ def represent_mapping(self, tag, mapping, flow_style=None): if not isinstance(mapping, OrderedDict): mapping.sort() for item_key, item_value in mapping: + if isinstance(item_value, UUID): + item_value = str(item_value) + node_key = self.represent_data(item_key) node_value = self.represent_data(item_value) + if not (isinstance(node_key, yaml.ScalarNode) and not node_key.style): best_style = False if not (isinstance(node_value, yaml.ScalarNode) and not node_value.style): diff --git a/rest_framework_yaml/parsers.py b/rest_framework_yaml/parsers.py index 2fbb744..8315347 100644 --- a/rest_framework_yaml/parsers.py +++ b/rest_framework_yaml/parsers.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals from django.conf import settings -from django.utils import six +import six from rest_framework.exceptions import ParseError from rest_framework.parsers import BaseParser