From 7fbeb8772636f93611b0621adce36a9d82752e3c Mon Sep 17 00:00:00 2001 From: Christopher Paolini Date: Thu, 15 Aug 2013 10:50:47 -0400 Subject: [PATCH] Update formatting.py Simple update that allows setting the title used in the Browseable API and disable suffix if desired. Class MyAPIView(viewsets.GenericViewSet): def Meta: view_name = 'API View' view_name_suffix = False --- rest_framework/utils/formatting.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py index 4bec83877..65d278ec5 100644 --- a/rest_framework/utils/formatting.py +++ b/rest_framework/utils/formatting.py @@ -49,6 +49,13 @@ def get_view_name(cls, suffix=None): """ Return a formatted name for an `APIView` class or `@api_view` function. """ + if hasattr(cls,'Meta'): + # this allows for a simple override of the name used in the template + if cls.Meta.view_name: + if cls.Meta.suffix: + return cls.Meta.view_name + ' ' + suffix + return cls.Meta.view_name + name = cls.__name__ name = _remove_trailing_string(name, 'View') name = _remove_trailing_string(name, 'ViewSet')