{"id":34057844,"url":"https://github.com/kit-oz/drf-complex-filter","last_synced_at":"2026-04-05T01:32:31.098Z","repository":{"id":45078824,"uuid":"312804436","full_name":"kit-oz/drf-complex-filter","owner":"kit-oz","description":"Declarative filter for Django ORM","archived":false,"fork":false,"pushed_at":"2025-01-20T19:11:24.000Z","size":62,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T13:04:37.569Z","etag":null,"topics":["django","django-orm","django-queries","django-queryset","django-rest-framework"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kit-oz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-14T11:36:51.000Z","updated_at":"2025-02-28T20:52:49.000Z","dependencies_parsed_at":"2024-10-20T08:09:34.191Z","dependency_job_id":null,"html_url":"https://github.com/kit-oz/drf-complex-filter","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":"0.17647058823529416","last_synced_commit":"0e5df225f92c0170cb5f447f321018f9cd5a4c2e"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/kit-oz/drf-complex-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kit-oz%2Fdrf-complex-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kit-oz%2Fdrf-complex-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kit-oz%2Fdrf-complex-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kit-oz%2Fdrf-complex-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kit-oz","download_url":"https://codeload.github.com/kit-oz/drf-complex-filter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kit-oz%2Fdrf-complex-filter/sbom","scorecard":{"id":561728,"data":{"date":"2025-08-11","repo":{"name":"github.com/kit-oz/drf-complex-filter","commit":"1a923d66eabda4870318227ab3eb91ba86314d6d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/python-publish.yml:16","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":1,"reason":"Found 5/29 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/kit-oz/drf-complex-filter/python-publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/kit-oz/drf-complex-filter/python-publish.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/python-publish.yml:32","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/python-publish.yml:19"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"22 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2021-9 / GHSA-fvgf-6h6h-3322","Warn: Project is vulnerable to: PYSEC-2021-99 / GHSA-p99v-5w3c-jqq9","Warn: Project is vulnerable to: PYSEC-2021-8 / GHSA-qm57-vhq3-3fwf","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2021-7 / GHSA-rxjp-mfm9-w4wr","Warn: Project is vulnerable to: PYSEC-2021-439 / GHSA-v6rh-hp5x-86rv","Warn: Project is vulnerable to: PYSEC-2021-6 / GHSA-xgxc-v2qg-chmh","Warn: Project is vulnerable to: PYSEC-2021-109 / GHSA-xpfp-f569-q3p2","Warn: Project is vulnerable to: GHSA-gw84-84pc-xp82","Warn: Project is vulnerable to: GHSA-2m57-hf25-phgg","Warn: Project is vulnerable to: PYSEC-2021-333 / GHSA-p5w8-wqhj-9hhf","Warn: Project is vulnerable to: PYSEC-2023-87 / GHSA-rrm6-wvj7-cwh2","Warn: Project is vulnerable to: PYSEC-2020-32 / GHSA-2m34-jcjv-45xf","Warn: Project is vulnerable to: PYSEC-2020-36 / GHSA-3gh2-xw74-jmcw","Warn: Project is vulnerable to: PYSEC-2020-34 / GHSA-fr28-569j-53c4","Warn: Project is vulnerable to: PYSEC-2020-35 / GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2020-33 / GHSA-m6gj-h9gm-gw44","Warn: Project is vulnerable to: GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2020-31 / GHSA-wpjr-j57x-wxfw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T13:54:37.147Z","repository_id":45078824,"created_at":"2025-08-20T13:54:37.147Z","updated_at":"2025-08-20T13:54:37.147Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31421869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T00:25:07.052Z","status":"ssl_error","status_checked_at":"2026-04-05T00:25:05.923Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-orm","django-queries","django-queryset","django-rest-framework"],"created_at":"2025-12-14T03:58:14.601Z","updated_at":"2026-04-05T01:32:31.081Z","avatar_url":"https://github.com/kit-oz.png","language":"Python","readme":"# Django Complex Filter\n\n[![Published on Django Packages](https://img.shields.io/badge/Published%20on-Django%20Packages-0c3c26)](https://djangopackages.org/packages/p/drf-complex-filter/)\n[![PyPI version](https://badge.fury.io/py/drf-complex-filter.svg)](https://badge.fury.io/py/drf-complex-filter)\n[![codecov](https://codecov.io/gh/kit-oz/drf-complex-filter/branch/main/graph/badge.svg?token=B6Z1LWBXOP)](https://codecov.io/gh/kit-oz/drf-complex-filter)\n[![Python Versions](https://img.shields.io/pypi/pyversions/drf-complex-filter.svg)](https://pypi.org/project/drf-complex-filter/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA powerful and flexible declarative filter for Django ORM that enables complex query construction through a simple JSON-based API. Perfect for building advanced filtering capabilities in your Django REST Framework applications.\n\n## Features\n\n- **Advanced Filtering**: Complex AND/OR operations with nested conditions\n- **Declarative Syntax**: Simple JSON-based query structure\n- **Dynamic Values**: Support for computed values and server-side calculations\n- **Related Model Queries**: Efficient subquery handling for related models\n- **Extensible**: Easy to add custom operators and value functions\n- **Type Safe**: Built-in operator validation\n- **DRF Integration**: Seamless integration with Django REST Framework\n\n## Installation\n\n```bash\npip install drf-complex-filter\n```\n\n## Quick Start\n\n1. Add `ComplexQueryFilter` to your ViewSet:\n\n```python\nfrom drf_complex_filter.filters import ComplexQueryFilter\n\nclass UserViewSet(ModelViewSet):\n    queryset = User.objects.all()\n    serializer_class = UserSerializer\n    filter_backends = [ComplexQueryFilter]\n```\n\n2. Make API requests with complex filters:\n\n```bash\n# Simple equality filter\nGET /users?filters={\"type\":\"operator\",\"data\":{\"attribute\":\"first_name\",\"operator\":\"=\",\"value\":\"John\"}}\n\n# Complex AND condition\nGET /users?filters={\"type\":\"and\",\"data\":[\n    {\"type\":\"operator\",\"data\":{\"attribute\":\"age\",\"operator\":\"\u003e\",\"value\":18}},\n    {\"type\":\"operator\",\"data\":{\"attribute\":\"is_active\",\"operator\":\"=\",\"value\":true}}\n]}\n```\n\n## Filter Types\n\n### 1. Simple Operator\n```python\n{\n    \"type\": \"operator\",\n    \"data\": {\n        \"attribute\": \"field_name\",\n        \"operator\": \"=\",\n        \"value\": \"value_to_compare\"\n    }\n}\n```\n\n### 2. AND Operator\n```python\n{\n    \"type\": \"and\",\n    \"data\": [\n        # List of operators to combine with AND\n    ]\n}\n```\n\n### 3. OR Operator\n```python\n{\n    \"type\": \"or\",\n    \"data\": [\n        # List of operators to combine with OR\n    ]\n}\n```\n\n## Available Operators\n\n| Operator | Description | Symbol |\n|----------|-------------|---------|\n| Is | Equality | = |\n| Is not | Inequality | != |\n| Contains | Case-insensitive contains | * |\n| Not contains | Case-insensitive not contains | ! |\n| Greater | Greater than | \u003e |\n| Greater or equal | Greater than or equal | \u003e= |\n| Less | Less than | \u003c |\n| Less or equal | Less than or equal | \u003c= |\n| In | Value in list | in |\n| Not in | Value not in list | not_in |\n| Current user | Current authenticated user | me |\n| Not current user | Not current authenticated user | not_me |\n\n## Advanced Features\n\n### Custom Operators\n\n1. Create your operator class:\n```python\nclass CustomOperators:\n    def get_operators(self):\n        return {\n            \"custom_op\": lambda f, v, r, m: Q(**{f\"{f}__custom\": v}),\n        }\n```\n\n2. Register in settings:\n```python\nCOMPLEX_FILTER_SETTINGS = {\n    \"COMPARISON_CLASSES\": [\n        \"drf_complex_filter.comparisons.CommonComparison\",\n        \"path.to.CustomOperators\",\n    ],\n}\n```\n\n### Dynamic Values\n\n1. Create value functions:\n```python\nclass CustomFunctions:\n    def get_functions(self):\n        return {\n            \"current_time\": lambda request, model: timezone.now(),\n        }\n```\n\n2. Register in settings:\n```python\nCOMPLEX_FILTER_SETTINGS = {\n    \"VALUE_FUNCTIONS\": [\n        \"drf_complex_filter.functions.DateFunctions\",\n        \"path.to.CustomFunctions\",\n    ],\n}\n```\n\n3. Use in filters:\n```python\n{\n    \"type\": \"operator\",\n    \"data\": {\n        \"attribute\": \"created_at\",\n        \"operator\": \"\u003e\",\n        \"value\": {\n            \"func\": \"current_time\",\n            \"kwargs\": {}\n        }\n    }\n}\n```\n\n### Related Model Queries\n\nUse `ModelName___` prefix for efficient subqueries:\n```python\n{\n    \"type\": \"operator\",\n    \"data\": {\n        \"attribute\": \"Profile___is_verified\",\n        \"operator\": \"=\",\n        \"value\": true\n    }\n}\n```\n\n## Requirements\n\n- Python \u003e= 3.6\n- Django \u003e= 3.0.0\n- Django REST Framework\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkit-oz%2Fdrf-complex-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkit-oz%2Fdrf-complex-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkit-oz%2Fdrf-complex-filter/lists"}