code: def get_transition_viewset_method(transition_name, **kwargs):
      '''
      Create a viewset method for the provided `transition_name`
      '''
      @detail_route(methods=['post'], **kwargs)
      def inner_func(self, request, pk=None, **kwargs):
          object = self.get_object()
          transition_method = getattr(object, transition_name)
  
          transition_method(by=self.request.user)
  
          if self.save_after_transition:
              object.save()
  
          serializer = self.get_serializer(object)
          return Response(serializer.data)
  
      return inner_funf get_transition_viewset_method(transition_name, **kwargs):
      '''
      Create a viewset method for the provided `transition_name`
      '''
      @detail_route(methods=['post'], **kwargs)
      def inner_func(self, request, pk=None, **kwargs):
          object = self.get_object()
          transition_method = getattr(object, transition_name)
  
          transition_method(by=self.request.user)
  
          if self.save_after_transition:
              object.save()
  
          serializer = self.get_serializer(object)
          return Response(serializer.data)
  
      return inner_func
docs: Create a viewset method for the provided `transition_name`