class MetaTermsViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): """ List all the Meta Terms """ queryset = MetaTerm.get_root_nodes() serializer_class = MetaTermsSerializer permission_classes = ( permissions.IsAuthenticated, IsApplyStaffUser, )
def __init__(self, *args, **kwargs): kwargs.pop('user') super().__init__(*args, **kwargs) self.fields['meta_terms'].queryset = MetaTerm.get_root_descendants( ).exclude(depth=2)