I want to filter my model with django-filter. It works fine if I filter by one id like:
http://localhost:8000/accommodations?accommodationType_id=1
But I don't know how I can filter by multiple ids like.
http://localhost:8000/accommodations?accommodationType_id=1,2
My actual ViewSet
looks like this:
class AccommodationViewSet(viewsets.ReadOnlyModelViewSet):
"""
REST API endpoint for 'accommodation' resource
"""
queryset = Accommodation.objects.all()
serializer_class = AccommodationSerializer
filter_backends = (filters.DjangoFilterBackend,)
filter_fields = ('accommodationType_id', 'name')
I hope there is an solution.
I found the following solution for my problem :)
https://gist.github.com/aBuder/654fb945f085b17358d8