Filter backend for DjangoRestFramework able to parse url parameters
Supports drf 3.5.x, 3.6.x, 3.7.x, 3.8.x Django 1.10.x, 1.11.x, 2.0.x, python 2.7, 3.6
The full documentation is at https://drf-querystringfilter.readthedocs.org.
class UserSerializer(ModelSerializer):
class Meta:
model = User
exclude = ()
class Users(ListAPIView):
serializer_class = UserSerializer
filter_fields = ['username', 'email', 'is_staff', 'date_joined']
filter_blacklist = None
filter_backends = (QueryStringFilterBackend,)
queryset = User.objects.all()
now you can query using...
- /users/?username=sax
- /users/?username__startswith=sa&date_joined__year=2000
- /users/?[email protected]
- /users/?is_staff=true
Stable | |||||
Development | |||||
Project home page: | https://github.com/saxix/drf-querystringfilter | ||||
Issue tracker: | https://github.com/saxix/drf-querystringfilter/issues?sort | ||||
Download: | http://pypi.python.org/pypi/drf-querystringfilter/ | ||||
Documentation: | https://drf-querystringfilter.readthedocs.org/en/latest/ |