  
  
  class TestActionAppliedToExistingRoute(TestCase):
      """
      Ensure `@detail_route` decorator raises an except when applied
      to an existing route
      """
  
      def test_exception_raised_when_action_applied_to_existing_route(self):
          class TestViewSet(viewsets.ModelViewSet):
 
</s> remove             @detail_route(methods=['post'])
 </s> add             @action(methods=['post'], detail=True) </s> remove             @detail_route(methods=['post'], permission_classes=[permissions.AllowAny])
 </s> add             @action(methods=['post'], detail=True, permission_classes=[permissions.AllowAny]) </s> remove def replace_methodname(format_string, methodname):
    """
    Partially format a format_string, swapping out any
    '{methodname}' or '{methodnamehyphen}' components.
    """
    methodnamehyphen = methodname.replace('_', '-')
    ret = format_string
    ret = ret.replace('{methodname}', methodname)
    ret = ret.replace('{methodnamehyphen}', methodnamehyphen)
    return ret


 </s> add 
    Ensure `@action` decorator raises an except when applied
  
  
  class TestActionAppliedToExistingRoute(TestCase):
      """
    Ensure `@action` decorator raises an except when applied
      to an existing route
      """
  
      def test_exception_raised_when_action_applied_to_existing_route(self):
          class TestViewSet(viewsets.ModelViewSet):
keep keep keep keep replace keep keep keep keep keep
 Rework dynamic list/detail actions (#5705)

* Merge list/detail route decorators into 'action'

* Merge dynamic routes, add 'detail' attribute

* Add 'ViewSet.get_extra_actions()'

* Refactor dynamic route checking & collection

* Refactor dynamic route generation

* Add 'ViewSet.detail' initkwarg

* Fixup schema test

* Add release notes for dynamic action changes

* Replace list/detail route decorators in tests

* Convert tabs to spaces in router docs

* Update docs

* Make 'detail' a required argument of 'action'

* Improve router docs 
tests/test_routers.py