We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eedcae5 commit c6bbf50Copy full SHA for c6bbf50
rest_framework_docs/api_endpoint.py
@@ -47,10 +47,13 @@ def __get_path__(self, parent_pattern):
47
48
def __get_allowed_methods__(self):
49
callback_cls = self.callback.cls
50
- return sorted(
51
- [force_str(m).upper() for m in callback_cls.http_method_names
52
- if hasattr(callback_cls, m) or (issubclass(callback_cls, ModelViewSet)
53
- and m in VIEWSET_METHODS.get(self.callback.suffix, ''))])
+
+ def is_method_allowed(method_name):
+ return hasattr(callback_cls, method_name) or (
+ issubclass(callback_cls, ModelViewSet) and
54
+ method_name in VIEWSET_METHODS.get(self.callback.suffix, []))
55
56
+ return sorted([force_str(name).upper() for name in callback_cls.http_method_names if is_method_allowed(name)])
57
58
def __get_docstring__(self):
59
return inspect.getdoc(self.callback)
0 commit comments