diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 60078947f..fb33d83c1 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -154,9 +154,10 @@ def action(methods=None, detail=None, name=None, url_path=None, url_name=None, * func.url_name = url_name if url_name else func.__name__.replace('_', '-') func.kwargs = kwargs func.kwargs.update({ - 'name': func.name, 'description': func.__doc__ or None }) + if 'suffix' not in kwargs: + func.kwargs['name'] = func.name return func return decorator diff --git a/tests/test_decorators.py b/tests/test_decorators.py index 7568513f3..f42e2e7c6 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -187,6 +187,16 @@ class ActionDecoratorTestCase(TestCase): 'description': 'Description', } + def test_detail_suffix(self): + @action(detail=True, suffix='Suffix') + def test_action(request): + raise NotImplementedError + + assert test_action.kwargs == { + 'description': None, + 'suffix': 'Suffix', + } + def test_detail_required(self): with pytest.raises(AssertionError) as excinfo: @action()