class SkillUserPaginatedViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = serializer_factory(serializers.SkillUserSerializer) filter_backends = (filters.OrderingFilter, ) ordering_fields = "__all__" def aggressive_queryset(self, aqs): return aqs.prefetch_filter(skills=lambda qs: qs.filter(name__startswith="ma")) class MiniPagination(pagination.PageNumberPagination): page_size = 5 page_size_query_param = 'page_size' max_page_size = 1000 pagination_class = MiniPagination
class SkillViewSet(viewsets.ModelViewSet): queryset = Skill.objects.all() serializer_class = serializer_factory(serializers.SkillSerializer)
class GroupUserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = serializer_factory(serializers.GroupUserSerializer)
class SkillUserForceAggressiveViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = serializer_factory( serializers.SkillUserSerializer, restriction=restriction_factory(restriction_class=ForceAggressiveRestriction) )
class UserViewSet2(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = serializer_factory( serializers.UserSerializer, restriction=restriction_factory(include_key="include", exclude_key="exclude"))
def _makeOne(self, serializer_class): from django_returnfields import serializer_factory return serializer_factory(serializer_class)