mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Py3/2 compat fixes for uncode view names/descriptions
This commit is contained in:
parent
09f2bdd219
commit
0c7d6062b2
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user