title: django-rest-framework: Adding bulk operation in a ModelViewSet
body: <p>I have many endpoints which use <code>ModelViewSet</code> to manage CRUD operations for my models.</p>
  
  <p>What I am trying to do, is to add bulk create, update, and delete at these same endpoints.  In other words, I want to add <code>POST</code>, <code>PUT</code>, <code>PATCH</code> and <code>DELETE</code> to the collection endpoint (e.g.: <code>/api/v1/my-model</code>).  There is a <code>django-rest-framework-bulk</code> package available, but it seems to be abandoned (hasn't been updated in 4 years) and I'm not comfortable using a package in production that is no longer active.</p>
  
  <p>Additionally, There are several similar questions here that have solutions, as well as blog posts I've found.  However, they all seem to use the base <code>ViewSet</code>, or <code>APIView</code>, which would require re-writing all of my existing <code>ModelViewSet</code> code.</p>
  
  <p>Finally, there is the option of using the <code>@action</code> decorator, however this would require me to have a separate list endpoint (e.g.- <code>/api/v1/my-model/bulk</code>) which I'd like to avoid.</p>
  
  <p>Are there any other ways to accomplish this while keeping my existing <code>ModelViewSet</code> views?  I've been looking at <code>GenericViewSet</code> and mixins, and am wondering if creating my own mixin might be the way to go.  However, looking at the mixin code, it doesn't appear that you can specify an HTTP Request method to be attached to a given mixin.</p>
  
  <p>Finally, I have tried creating a separate <code>ViewSet</code> that accepts PUT and adding it to my URLs, but this doesn't work (I get a 405 Method not allowed when I try to PUT to <code>/api/v1/my-model</code>).  The code I tried looks like this:</p>
  
  <pre class="lang-py prettyprint-override"><code># views.py
  class MyModelViewSet(viewsets.ModelViewSet):
      serializer_class = MyModelSerializer
      permission_classes = (IsAuthenticated,)
      queryset = MyModel.objects.all()
      paginator = None
  
  class ListMyModelView(viewsets.ViewSet):
      permission_classes = (IsAuthenticated,)
  
      def put(self, request):
          # Code for updating list of models will go here.
  
          return Response({'test': 'list put!'})
  
  
  # urls.py
  router = DefaultRouter(trailing_slash=False)
  router.register(r'my-model', MyModelViewSet)
  router.register(r'my-model', ListMyModelView, base_name='list-my-model')
  
  urlpatterns = [
      path('api/v1/', include(router.urls)),
      # more paths for auth, admin, etc..
  ]
  </code></pre>
  
  <p>Thoughts?</p>