diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 05880691e7c..4f7a22b775b 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -144,11 +144,12 @@ def action(methods=None, detail=True, name=None, url_name=None, url_path=None, * def decorator(func): func.bind_to_methods = methods func.detail = detail + func.name = name or pretty_name(func.__name__) 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__), + 'name': func.name, 'description': func.__doc__ or None }) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 3298294ce24..4b6b8c740e1 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -606,6 +606,11 @@ def get_description(self, view, status_code): def get_breadcrumbs(self, request): return get_breadcrumbs(request.path, request) + def get_extra_actions(self, view): + if hasattr(view, 'get_extra_action_url_map'): + return view.get_extra_action_url_map() + return None + def get_filter_form(self, data, view, request): if not hasattr(view, 'get_queryset') or not hasattr(view, 'filter_backends'): return @@ -692,6 +697,8 @@ def get_context(self, data, accepted_media_type, renderer_context): 'delete_form': self.get_rendered_html_form(data, view, 'DELETE', request), 'options_form': self.get_rendered_html_form(data, view, 'OPTIONS', request), + 'extra_actions': self.get_extra_actions(view), + 'filter_form': self.get_filter_form(data, view, request), 'raw_data_put_form': raw_data_put_form, diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html index 14007aa52e1..db622d74ac7 100644 --- a/rest_framework/templates/rest_framework/base.html +++ b/rest_framework/templates/rest_framework/base.html @@ -128,6 +128,20 @@

Are you sure you want to delete this {{ name }}?

{% endif %} + {% if extra_actions %} + + {% endif %} + {% if filter_form %}