3 ms·
It's not true at all. I've done nested routers in DRF plenty of times. router = DefaultRouter() router.register('users/(?P<user_id>\d+)/teams', UserTea
by jhgg 12y ago
It's not true at all. I've done nested routers in DRF plenty of times.
router = DefaultRouter()
router.register('users/(?P<user_id>\d+)/teams', UserTeamViewSet)
You can then access user_id via self.kwargs['user_id'] from within the viewset. And the team ID is implicitly added by the router to support list (and update), and retrieve (delete, put, patch) methods. user_id is also passed as a kwarg to the dispatched method (create, retrieve, etc...)