Hello, i'm new with DRF and don't understand too much about the schemas and 
how to use get_filter_fields.

Suppose i have defined:

class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer
    filter_class = UserFilter

This works perfectly in the browsable API, but I would like to send through 
my API what are the available fields to filters, and the possibles choices 
to put on them, so the frontend can have the information about what are the 
filters to show and which options.. So i thought about send the filter 
"schema" to deal with this, and tried to define a SchemaView like this:



class UserFilterSchemaView(APIView):
    renderer_classes = [CoreJSONRenderer]

    def get(self, request):
        generator = schemas.SchemaGenerator(title='User filters')
        uservws = UserViewSet()
        filters = generator.get_filter_fields(path='/users/', 
view=uservws.list(request), method=request.method)
        return Response(filters)

But i'm getting some errors (for example 'UserViewSet' object has no 
attribute 'request') and in the documentation i couldn't find any example 
of use of this method or any other similar..

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to