From 3441d6f44fd7bd8cc00eb49d127825bd55fc00b3 Mon Sep 17 00:00:00 2001 From: msaelices Date: Tue, 15 Mar 2016 01:28:46 +0100 Subject: [PATCH] Fix a TypeError fetching the allowed_methods when the ModelViewSet has no prefix in the callback (when is the class instance). --- rest_framework_docs/api_endpoint.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework_docs/api_endpoint.py b/rest_framework_docs/api_endpoint.py index 15ce38a..71900c6 100644 --- a/rest_framework_docs/api_endpoint.py +++ b/rest_framework_docs/api_endpoint.py @@ -47,8 +47,10 @@ def __get_path__(self, parent_pattern): def __get_allowed_methods__(self): callback_cls = self.callback.cls - return sorted([force_str(m).upper() for m in callback_cls.http_method_names if hasattr(callback_cls, m) or - (issubclass(callback_cls, ModelViewSet) and m in VIEWSET_METHODS.get(self.callback.suffix))]) + return sorted( + [force_str(m).upper() for m in callback_cls.http_method_names + if hasattr(callback_cls, m) or (issubclass(callback_cls, ModelViewSet) + and m in VIEWSET_METHODS.get(self.callback.suffix, ''))]) def __get_docstring__(self): return inspect.getdoc(self.callback)