Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Represent UUID's as strings #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ wheel==0.24.0

# MkDocs for documentation previews/deploys
mkdocs==0.11.1
six==1.14.0
3 changes: 1 addition & 2 deletions rest_framework_yaml/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions rest_framework_yaml/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion rest_framework_yaml/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down