Metadata-Version: 2.1
Name: django-rest-framework-query-tools
Version: 1.1
Summary: The package allows developers to enhance filtering capabilities within Django Rest Framework views by simply specifying the desired filter fields. By incorporating the URLFilter into views or adding it to the Django Rest Framework settings, the package streamlines the filtering process.
Home-page: https://github.com/joe-philip/django_rest_framework_query_tools
Author: Joe Philip
Author-email: joe.philip@hotmail.co.in
License: MIT License
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Description-Content-Type: text/markdown
Requires-Dist: djangorestframework >=3.14.0
Requires-Dist: toml

Django Rest Framework Query Tools

This package facilitates filter operations via query parameters, simplifying the filtering process for Django Rest Framework views.
Installation

Install via pip:

```bash
pip install django-rest-framework-query-tools
```

Usage
Quick Example

Suppose you have a Books model with fields like author, title, etc. To filter Books by author using query params:

In your views.py, specify the field(s) to filter using filter_fields:

```python

from rest_framework.views import APIView
from rest_framework import generics
from rest_framework import filters
from django_rest_framework_query_tools.filters.url_fliter import URLFilter

class BooksListView(generics.ListAPIView):
    queryset = Books.objects.all()
    serializer_class = BookSerializer
    filter_backends = [URLFilter]
    filter_fields = ('author',)
```

Now, you can perform filtering by passing query parameters:

```plaintext
/v1/books?author=name
```

Integration
Method 1: Integration in views.py

Import QueryParamsFilter and use it as a filter backend:

```python

from drf_query_tools.filters import QueryParamsFilter

class BooksListView(generics.ListAPIView):
    # ...
    filter_backends = [QueryParamsFilter]
    filter_fields = ('author',)
    # ...
```

Method 2: Global Integration via settings.py

Add the QueryParamsFilter to your Django Rest Framework settings:

```python

REST_FRAMEWORK = {
    'DEFAULT_FILTER_BACKENDS': [
        'django_rest_framework_query_tools.filters.url_fliter.URLFilter'
    ]
}
```

Contributing

Feel free to contribute by opening issues or submitting pull requests!
License

This project is licensed under the MIT License - see the LICENSE file for details

