diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index d94c81df4..244c14d39 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -25,11 +25,12 @@ from django.utils.decorators import classonlymethod from django.views.decorators.csrf import csrf_exempt from rest_framework import generics, mixins, views +from rest_framework.decorators import MethodMapper from rest_framework.reverse import reverse def _is_extra_action(attr): - return hasattr(attr, 'mapping') + return hasattr(attr, 'mapping') and isinstance(attr.mapping, MethodMapper) class ViewSetMixin: diff --git a/tests/test_viewsets.py b/tests/test_viewsets.py index fc62cc981..921daf186 100644 --- a/tests/test_viewsets.py +++ b/tests/test_viewsets.py @@ -90,7 +90,6 @@ class ActionViewSetWithMapping(ActionViewSet): mapper = ThingWithMapping() - router = SimpleRouter() router.register(r'actions', ActionViewSet) router.register(r'actions-alt', ActionViewSet, basename='actions-alt') @@ -156,6 +155,7 @@ class InitializeViewSetsTestCase(TestCase): self.assertNotIn(attribute, dir(bare_view)) self.assertIn(attribute, dir(view)) + class GetExtraActionsTests(TestCase): def test_extra_actions(self):