In my viewSet I am doing a query,
queryset= Books.objects.all();
Now from an ajax call I get my filter values from UI i.e. age,gender, etc. of
You can simply get the request.GET content as a dict (making sure to convert the values to string or a desired type as they'd be list by default i.e: dict(request.GET)
would give you something like {u'a': [u'val']}
.
Once you are sure you have a dictionary of keys matching your model fields, you can simply do:
filtered = queryset.filter(**dict_container)