Skip to content

Commit

Permalink
Add name/desc override to action
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby committed Nov 18, 2017
1 parent 2ab9ba1 commit 27a2e93
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rest_framework/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import types
import warnings

from django.forms.utils import pretty_name
from django.utils import six

from rest_framework.views import APIView
Expand Down Expand Up @@ -130,7 +131,7 @@ def decorator(func):
return decorator


def action(methods=None, detail=True, url_name=None, url_path=None, **kwargs):
def action(methods=None, detail=True, name=None, url_name=None, url_path=None, **kwargs):
"""
Mark a ViewSet method as a routable action.
Expand All @@ -146,6 +147,11 @@ def decorator(func):
func.url_name = url_name or func.__name__
func.url_path = url_path or func.__name__
func.kwargs = kwargs
func.kwargs.update({
'name': name or pretty_name(func.__name__),
'description': func.__doc__ or None
})

return func
return decorator

Expand Down

0 comments on commit 27a2e93

Please sign in to comment.