diff options
| author | Tom Christie | 2013-02-22 20:18:16 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-02-22 20:18:16 +0000 |
| commit | 0c7d6062b2b327f1fb4051a898212499e33daa54 (patch) | |
| tree | 25331a6296f0b75c0329c85228fd99ecbca18818 | |
| parent | 09f2bdd21998dd64b38285ee244a760f711793f5 (diff) | |
| download | django-rest-framework-0c7d6062b2b327f1fb4051a898212499e33daa54.tar.bz2 | |
Py3/2 compat fixes for uncode view names/descriptions
| -rw-r--r-- | rest_framework/renderers.py | 11 | ||||
| -rw-r--r-- | rest_framework/views.py | 7 |
2 files changed, 8 insertions, 10 deletions
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index d041dd4f..50531b14 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 a3a3ac25..69377bc0 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) |
