chibisov / drf-extensions

DRF-extensions is a collection of custom extensions for Django REST Framework
http://chibisov.github.io/drf-extensions/docs
MIT License
1.47k stars 208 forks source link

Can't get the nested routing to work after reading the docs. #338

Open Aryan3212 opened 1 year ago

Aryan3212 commented 1 year ago

Nested routes

In the doc, in this section it says to create views like this but won't I need a queryset or get_queryset()defined here? Just want to understand what's happening here. I found a workaround in another issue posted here to use self.filter_queryset_by_parents_lookups.

 yourapp.views
from rest_framework_extensions.mixins import NestedViewSetMixin

class UserViewSet(NestedViewSetMixin, ModelViewSet):
    model = UserModel

class GroupViewSet(NestedViewSetMixin, ModelViewSet):
    model = GroupModel

class PermissionViewSet(NestedViewSetMixin, ModelViewSet):
    model = PermissionModel