File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ def get_view_name(view):
30
30
31
31
This function is the default for the `VIEW_NAME_FUNCTION` setting.
32
32
"""
33
+ if view .name :
34
+ return view .name
35
+
33
36
name = view .__class__ .__name__
34
37
name = formatting .remove_trailing_string (name , 'View' )
35
38
name = formatting .remove_trailing_string (name , 'ViewSet' )
@@ -50,7 +53,11 @@ def get_view_description(view, html=False):
50
53
51
54
This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
52
55
"""
53
- description = view .__class__ .__doc__ or ''
56
+ if view .description :
57
+ return view .description
58
+ else :
59
+ description = view .__class__ .__doc__ or ''
60
+
54
61
description = formatting .dedent (smart_text (description ))
55
62
if html :
56
63
return formatting .markup_description (description )
@@ -107,6 +114,10 @@ def exception_handler(exc, context):
107
114
108
115
class APIView (View ):
109
116
117
+ # Allow the view name and description to be set by the initkwargs.
118
+ name = None
119
+ description = None
120
+
110
121
# The following policies may be set at either globally, or per-view.
111
122
renderer_classes = api_settings .DEFAULT_RENDERER_CLASSES
112
123
parser_classes = api_settings .DEFAULT_PARSER_CLASSES
You can’t perform that action at this time.
0 commit comments