I have this REST API:
urlpatterns = [
path('admin/', admin.site.urls),
path('users/', UserViewSet.as_view({'get': 'list',
'post': 'create',
'delete': 'delete'})),
path('users/<uuid:pk>/video/', UserViewSet.as_view({'post': 'video'}))
]
How can i rewrite this with routers?
Default router with register method creates API -> GET users/ and POST users/ and also DELETE /users/{id} but it's different from current, because i need DELETE /users/ endpoint.
Or, maybe, in this situation it would be more correct to use my code with dictionaries?
assuming that
UserViewSetis indeed a viewset, you can use the restframework's default router to register the router for/users/, and then add an action to handle you/video/route from that viewset.urls.py
viewsets.py
Edit
To create a bulk
DELETEof users endpoint, I would create a Mixin class, as there is no django mixin for Deleting on the index of a router..And inherit from this class in your viewset
viewsets.py