aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils
diff options
context:
space:
mode:
authorIgor Kalat2013-06-26 22:12:02 +0200
committerIgor Kalat2013-06-26 22:12:02 +0200
commitc8b0e6c40f6bcf447aa539ff98b9985aa53032ce (patch)
tree68568ce75703347d503e39d525baf0e2c800c6c9 /rest_framework/utils
parent2bf5f6305030d5ebbd5a8a0fd5c31586c08a558d (diff)
downloaddjango-rest-framework-c8b0e6c40f6bcf447aa539ff98b9985aa53032ce.tar.bz2
Refactored get_view_description, moved appropriate tests to test_description.py
Diffstat (limited to 'rest_framework/utils')
-rw-r--r--rest_framework/utils/formatting.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py
index a2a5609c..4bec8387 100644
--- a/rest_framework/utils/formatting.py
+++ b/rest_framework/utils/formatting.py
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
from django.utils.html import escape
from django.utils.safestring import mark_safe
-from rest_framework.compat import apply_markdown
+from rest_framework.compat import apply_markdown, smart_text
import re
@@ -24,11 +24,6 @@ def _remove_leading_indent(content):
Remove leading indent from a block of text.
Used when generating descriptions from docstrings.
"""
- try:
- content = content.decode('utf-8')
- except (AttributeError, UnicodeEncodeError):
- pass # the string should keep the default 'ascii' encoding in
- # Python 2.x or stay a unicode string in Python 3.x
whitespace_counts = [len(line) - len(line.lstrip(' '))
for line in content.splitlines()[1:] if line.lstrip()]
@@ -68,7 +63,7 @@ def get_view_description(cls, html=False):
Return a description for an `APIView` class or `@api_view` function.
"""
description = cls.__doc__ or ''
- description = _remove_leading_indent(description)
+ description = _remove_leading_indent(smart_text(description))
if html:
return markup_description(description)
return description