-
Notifications
You must be signed in to change notification settings - Fork 19
Support custom Querystring parameters #42
Comments
I have a similar problem currently, when using the serializer extensions. Serializer extensions use an additional GET parameter
While the JS client does not accept additional querystring parameters out-of-the-box, they can be added for the class SerializerExtensionFilter(BaseFilterBackend):
def get_schema_fields(self, view):
return [
coreapi.Field(name="expand",
schema=coreschema.String(
title="expand",
description="Comma-separated list of additional fields to include"
),
required=False,
location='query'),
]
def filter_queryset(self, request, queryset, view):
# don't filter anything
return queryset
class MyViewset(viewsets.ModelViewSet):
queryset = MyModel.objects.all()
serializer_class = serializers.MySerializer
filter_backends = (SerializerExtensionFilter,) Unfortunately it is not that simple for the |
Update: modifying the generated schema is much easier in DRF 3.7.0: http://www.django-rest-framework.org/topics/3.7-announcement/#customizing-api-docs-schema-generation So if you can upgrade to 3.7.0 (e.g. you are not on Django 1.8, like me), I'd say a customized schema is the way to go in your scenario. |
If you want more info about your issue, we are discussing that here: #38 |
I want to append in querystring of some APIs a
language
key/value so i can translate messages for every “translatable API“.The js is very strict so the
language
key, used in myget_queryset
ordispatch
method and not defined in my view's filters, is not recognized and the call to the API is denied from JS!@tomchristie how can i resolve this problem according to you (drf filters are strongly coupled with models) ?
Thank you all in advance.
The text was updated successfully, but these errors were encountered: