diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index d041dd4f5..50531b141 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -14,8 +14,10 @@ import json from django import forms from django.http.multipartparser import parse_header from django.template import RequestContext, loader, Template -from django.utils.encoding import force_unicode 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 from rest_framework.compat import yaml from rest_framework.exceptions import ConfigurationError from rest_framework.settings import api_settings @@ -23,9 +25,6 @@ from rest_framework.request import clone_request from rest_framework.utils import encoders from rest_framework.utils.breadcrumbs import get_breadcrumbs from rest_framework import exceptions, parsers, status, VERSION -from rest_framework.compat import StringIO -from rest_framework.compat import six -from rest_framework.compat import smart_text class BaseRenderer(object): @@ -440,13 +439,13 @@ class BrowsableAPIRenderer(BaseRenderer): try: return view.get_name() except AttributeError: - return force_unicode(view.__class__.__name__) + return smart_text(view.__class__.__name__) def get_description(self, view): try: return view.get_description(html=True) except AttributeError: - return force_unicode(view.__doc__) + return smart_text(view.__doc__ or '') def render(self, data, accepted_media_type=None, renderer_context=None): """ diff --git a/rest_framework/views.py b/rest_framework/views.py index a3a3ac254..69377bc09 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -4,12 +4,11 @@ Provides an APIView class that is used as the base of all class-based views. from __future__ import unicode_literals from django.core.exceptions import PermissionDenied from django.http import Http404 -from django.utils.encoding import force_unicode from django.utils.html import escape from django.utils.safestring import mark_safe from django.views.decorators.csrf import csrf_exempt from rest_framework import status, exceptions -from rest_framework.compat import View, apply_markdown +from rest_framework.compat import View, apply_markdown, smart_text from rest_framework.response import Response from rest_framework.request import Request from rest_framework.settings import api_settings @@ -97,7 +96,7 @@ class APIView(View): Override to customize. """ # TODO: deprecate? - name = force_unicode(self.__class__.__name__) + name = self.__class__.__name__ name = _remove_trailing_string(name, 'View') return _camelcase_to_spaces(name) @@ -107,7 +106,7 @@ class APIView(View): Override to customize. """ # TODO: deprecate? - description = force_unicode(self.__doc__) or u'' + description = self.__doc__ or '' description = _remove_leading_indent(description) if html: return self.markup_description(description)