mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
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
This commit is contained in:
parent
c245fc6cde
commit
7fbeb87726
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user