diff options
| author | Tom Christie | 2013-02-22 05:37:15 -0800 | 
|---|---|---|
| committer | Tom Christie | 2013-02-22 05:37:15 -0800 | 
| commit | 44b59969ce14f066b0c04e43f5c6a6124e534526 (patch) | |
| tree | d6b737c620230b1591bdd9f670cb124a03f58e05 /rest_framework | |
| parent | 5d37612e7877fd4ef6a963930a1208cc6c548306 (diff) | |
| parent | aa95ccbab79d8270e60bec91c01808c912799ca7 (diff) | |
| download | django-rest-framework-44b59969ce14f066b0c04e43f5c6a6124e534526.tar.bz2 | |
Merge pull request #672 from wronglink/unicode__doc__
Fixed UnicodeDecodeError on get_name and get_description methods
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/renderers.py | 5 | ||||
| -rw-r--r-- | rest_framework/views.py | 5 | 
2 files changed, 6 insertions, 4 deletions
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 637904c4..bc5d0ed5 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -14,6 +14,7 @@ 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 rest_framework.compat import yaml  from rest_framework.exceptions import ConfigurationError  from rest_framework.settings import api_settings @@ -405,13 +406,13 @@ class BrowsableAPIRenderer(BaseRenderer):          try:              return view.get_name()          except AttributeError: -            return view.__doc__ +            return force_unicode(view.__doc__)      def get_description(self, view):          try:              return view.get_description(html=True)          except AttributeError: -            return view.__doc__ +            return force_unicode(view.__doc__)      def render(self, data, accepted_media_type=None, renderer_context=None):          """ diff --git a/rest_framework/views.py b/rest_framework/views.py index fa742582..a3a3ac25 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -4,6 +4,7 @@ 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 @@ -96,7 +97,7 @@ class APIView(View):          Override to customize.          """          # TODO: deprecate? -        name = self.__class__.__name__ +        name = force_unicode(self.__class__.__name__)          name = _remove_trailing_string(name, 'View')          return _camelcase_to_spaces(name) @@ -106,7 +107,7 @@ class APIView(View):          Override to customize.          """          # TODO: deprecate? -        description = self.__doc__ or '' +        description = force_unicode(self.__doc__) or u''          description = _remove_leading_indent(description)          if html:              return self.markup_description(description)  | 
