diff options
| author | Tom Christie | 2013-04-26 14:59:21 +0100 | 
|---|---|---|
| committer | Tom Christie | 2013-04-26 14:59:21 +0100 | 
| commit | 8fa79a7fd38dda015afa658084361c6da2856e46 (patch) | |
| tree | ef8080a9d24b488402429c0bae101e3f395f1f8b /rest_framework/utils | |
| parent | e301e2d974649a932ab9a7ca32199c068fa30495 (diff) | |
| download | django-rest-framework-8fa79a7fd38dda015afa658084361c6da2856e46.tar.bz2 | |
Deal with List/Instance suffixes for viewsets
Diffstat (limited to 'rest_framework/utils')
| -rw-r--r-- | rest_framework/utils/breadcrumbs.py | 3 | ||||
| -rw-r--r-- | rest_framework/utils/formatting.py | 7 | 
2 files changed, 7 insertions, 3 deletions
diff --git a/rest_framework/utils/breadcrumbs.py b/rest_framework/utils/breadcrumbs.py index 18b3b207..8f8e5710 100644 --- a/rest_framework/utils/breadcrumbs.py +++ b/rest_framework/utils/breadcrumbs.py @@ -21,7 +21,8 @@ def get_breadcrumbs(url):                  # Don't list the same view twice in a row.                  # Probably an optional trailing slash.                  if not seen or seen[-1] != view: -                    breadcrumbs_list.insert(0, (get_view_name(view.cls), prefix + url)) +                    suffix = getattr(view, 'suffix', None) +                    breadcrumbs_list.insert(0, (get_view_name(view.cls, suffix), prefix + url))                      seen.append(view)          if url == '': diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py index 79566db1..ebadb3a6 100644 --- a/rest_framework/utils/formatting.py +++ b/rest_framework/utils/formatting.py @@ -45,14 +45,17 @@ def _camelcase_to_spaces(content):      return ' '.join(content.split('_')).title() -def get_view_name(cls): +def get_view_name(cls, suffix=None):      """      Return a formatted name for an `APIView` class or `@api_view` function.      """      name = cls.__name__      name = _remove_trailing_string(name, 'View')      name = _remove_trailing_string(name, 'ViewSet') -    return _camelcase_to_spaces(name) +    name = _camelcase_to_spaces(name) +    if suffix: +        name += ' ' + suffix +    return name  def get_view_description(cls, html=False):  | 
