Skip to content

Commit 7a56175

Browse files
Fix empty doctstring for viewsets when docstring is only defined at class-level
1 parent 77dc489 commit 7a56175

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rest_framework_docs/api_endpoint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ def __get_allowed_methods__(self):
110110
)
111111
viewset_methods = list(viewset_methods)
112112
if len(set(funcs)) == 1:
113-
self.docstring = inspect.getdoc(getattr(self.callback.cls, funcs[0]))
114-
113+
func_docstring = inspect.getdoc(getattr(self.callback.cls, funcs[0]))
114+
if func_docstring is not None:
115+
self.docstring = func_docstring
115116
view_methods = [force_str(m).upper() for m in self.callback.cls.http_method_names if hasattr(self.callback.cls, m)]
116117
return viewset_methods + view_methods
117118

0 commit comments

Comments
 (0)