# Path: rest_framework_extensions/mixins.py
# class NestedViewSetMixin:
#     def get_queryset(self):
#         return self.filter_queryset_by_parents_lookups(
#             super().get_queryset()
#         )
# 
#     def filter_queryset_by_parents_lookups(self, queryset):
#         parents_query_dict = self.get_parents_query_dict()
#         if parents_query_dict:
#             try:
#                 return queryset.filter(**parents_query_dict)
#             except ValueError:
#                 raise Http404
#         else:
#             return queryset
# 
#     def get_parents_query_dict(self):
#         result = {}
#         for kwarg_name, kwarg_value in self.kwargs.items():
#             if kwarg_name.startswith(extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX):
#                 query_lookup = kwarg_name.replace(
#                     extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX,
#                     '',
#                     1
#                 )
#                 query_value = kwarg_value
#                 result[query_lookup] = query_value
#         return result
# 
# Path: tests_app/tests/functional/routers/extended_default_router/models.py
# class DefaultRouterUserModel(models.Model):
#     name = models.CharField(max_length=10)
#     groups = models.ManyToManyField('DefaultRouterGroupModel', related_name='user_groups')
# 
# class DefaultRouterGroupModel(models.Model):
#     name = models.CharField(max_length=10)
#     permissions = models.ManyToManyField('DefaultRouterPermissionModel')
# 
# class DefaultRouterPermissionModel(models.Model):
#     name = models.CharField(max_length=10)


from rest_framework.viewsets import ModelViewSet
from rest_framework_extensions.mixins import NestedViewSetMixin
from .models import (
    DefaultRouterUserModel,
    DefaultRouterGroupModel,
    DefaultRouterPermissionModel,
)




class UserViewSet(NestedViewSetMixin, ModelViewSet):
    queryset = DefaultRouterUserModel.objects.all()


class GroupViewSet(NestedViewSetMixin, ModelViewSet):

# Path: rest_framework_extensions/mixins.py
# class NestedViewSetMixin:
#     def get_queryset(self):
#         return self.filter_queryset_by_parents_lookups(
#             super().get_queryset()
#         )
# 
#     def filter_queryset_by_parents_lookups(self, queryset):
#         parents_query_dict = self.get_parents_query_dict()
#         if parents_query_dict:
#             try:
#                 return queryset.filter(**parents_query_dict)
#             except ValueError:
#                 raise Http404
#         else:
#             return queryset
# 
#     def get_parents_query_dict(self):
#         result = {}
#         for kwarg_name, kwarg_value in self.kwargs.items():
#             if kwarg_name.startswith(extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX):
#                 query_lookup = kwarg_name.replace(
#                     extensions_api_settings.DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX,
#                     '',
#                     1
#                 )
#                 query_value = kwarg_value
#                 result[query_lookup] = query_value
#         return result
# 
# Path: tests_app/tests/functional/routers/extended_default_router/models.py
# class DefaultRouterUserModel(models.Model):
#     name = models.CharField(max_length=10)
#     groups = models.ManyToManyField('DefaultRouterGroupModel', related_name='user_groups')
# 
# class DefaultRouterGroupModel(models.Model):
#     name = models.CharField(max_length=10)
#     permissions = models.ManyToManyField('DefaultRouterPermissionModel')
# 
# class DefaultRouterPermissionModel(models.Model):
#     name = models.CharField(max_length=10)


# Path: tests_app/tests/functional/routers/extended_default_router/views.py
from rest_framework.viewsets import ModelViewSet
from rest_framework_extensions.mixins import NestedViewSetMixin
from .models import (
    DefaultRouterUserModel,
    DefaultRouterGroupModel,
    DefaultRouterPermissionModel,
)





class UserViewSet(NestedViewSetMixin, ModelViewSet):
    queryset = DefaultRouterUserModel.objects.all()


class GroupViewSet(NestedViewSetMixin, ModelViewSet):

    queryset = DefaultRouterGroupModel.objects.all()