{"id":30432993,"url":"https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions","last_synced_at":"2025-08-22T22:02:29.654Z","repository":{"id":45351723,"uuid":"76878964","full_name":"evenicoulddoit/django-rest-framework-serializer-extensions","owner":"evenicoulddoit","description":"Extensions to help DRY up Django Rest Framework serializers","archived":false,"fork":false,"pushed_at":"2024-03-18T10:41:40.000Z","size":177,"stargazers_count":250,"open_issues_count":8,"forks_count":24,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T01:17:16.344Z","etag":null,"topics":["django","django-rest-framework","hashids"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evenicoulddoit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/contributing.md","funding":null,"license":"LICENSE.md","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":"2016-12-19T16:38:27.000Z","updated_at":"2025-06-01T20:56:39.000Z","dependencies_parsed_at":"2024-06-18T22:59:49.806Z","dependency_job_id":"54bab681-8062-40b4-ab5d-c892c8ca2f46","html_url":"https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions","commit_stats":{"total_commits":90,"total_committers":8,"mean_commits":11.25,"dds":0.3111111111111111,"last_synced_commit":"abed9de305990c9551da999d442c5444270b2d38"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/evenicoulddoit/django-rest-framework-serializer-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evenicoulddoit%2Fdjango-rest-framework-serializer-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evenicoulddoit%2Fdjango-rest-framework-serializer-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evenicoulddoit%2Fdjango-rest-framework-serializer-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evenicoulddoit%2Fdjango-rest-framework-serializer-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evenicoulddoit","download_url":"https://codeload.github.com/evenicoulddoit/django-rest-framework-serializer-extensions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evenicoulddoit%2Fdjango-rest-framework-serializer-extensions/sbom","scorecard":{"id":386086,"data":{"date":"2025-08-11","repo":{"name":"github.com/evenicoulddoit/django-rest-framework-serializer-extensions","commit":"c5f885674885335514758ec7fc7834408aaf20a3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"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":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"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":"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":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","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":"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":"Code-Review","score":2,"reason":"Found 5/22 approved changesets -- score normalized to 2","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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/evenicoulddoit/django-rest-framework-serializer-extensions/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/evenicoulddoit/django-rest-framework-serializer-extensions/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/evenicoulddoit/django-rest-framework-serializer-extensions/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:26","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 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":"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":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"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":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 2.0.0 not signed: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/22229536","Warn: release artifact 1.0.0 not signed: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/16885872","Warn: release artifact 0.5.4 not signed: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/9019246","Warn: release artifact 0.5.2 not signed: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/6756432","Warn: release artifact 2.0.0 does not have provenance: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/22229536","Warn: release artifact 1.0.0 does not have provenance: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/16885872","Warn: release artifact 0.5.4 does not have provenance: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/9019246","Warn: release artifact 0.5.2 does not have provenance: https://api.github.com/repos/evenicoulddoit/django-rest-framework-serializer-extensions/releases/6756432"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"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 28 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":"46 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2014-5 / GHSA-296w-6qhq-gf92","Warn: Project is vulnerable to: PYSEC-2011-2 / GHSA-3jqw-crqj-w8qw","Warn: Project is vulnerable to: PYSEC-2012-3 / GHSA-59w8-4wm2-4xw8","Warn: Project is vulnerable to: PYSEC-2012-4 / GHSA-5h2q-4hrp-v9rr","Warn: Project is vulnerable to: PYSEC-2014-6 / GHSA-625g-gx8c-xcmg","Warn: Project is vulnerable to: PYSEC-2015-8 / GHSA-6565-fg86-6jcx","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2012-2 / GHSA-78vx-ggch-wghm","Warn: Project is vulnerable to: PYSEC-2015-9 / GHSA-7fq8-4pv5-5w5c","Warn: Project is vulnerable to: PYSEC-2015-4 / GHSA-7qfw-j7hp-v45g","Warn: Project is vulnerable to: PYSEC-2011-9 / GHSA-7wph-fc4w-wqp2","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2014-2 / GHSA-89hj-xfx5-7q66","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2014-4 / GHSA-f7cm-ccfp-3q4r","Warn: Project is vulnerable to: PYSEC-2016-16 / GHSA-fp6p-5xvw-m74f","Warn: Project is vulnerable to: PYSEC-2011-8 / GHSA-fwr5-q9rx-294f","Warn: Project is vulnerable to: PYSEC-2015-5 / GHSA-gv98-g628-m9x5","Warn: Project is vulnerable to: PYSEC-2015-20 / GHSA-h582-2pch-3xv3","Warn: Project is vulnerable to: PYSEC-2011-5 / GHSA-h95j-h2rv-qrg4","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2015-6 / GHSA-jhjg-w2cp-5j44","Warn: Project is vulnerable to: PYSEC-2016-15 / GHSA-pw27-w7w4-9qc7","Warn: Project is vulnerable to: PYSEC-2015-10 / GHSA-q5qw-4364-5hhm","Warn: Project is vulnerable to: PYSEC-2011-4 / GHSA-rm2j-x595-q9cj","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2014-1 / GHSA-rvq6-mrpv-m6rm","Warn: Project is vulnerable to: PYSEC-2014-7 / GHSA-rw75-m7gp-92m3","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2014-3 / GHSA-wqjj-hx84-v449","Warn: Project is vulnerable to: PYSEC-2011-3 / GHSA-wxg3-mfph-qg9w","Warn: Project is vulnerable to: PYSEC-2011-1 / GHSA-x88j-93vc-wpmp","Warn: Project is vulnerable to: PYSEC-2007-1","Warn: Project is vulnerable to: PYSEC-2008-1","Warn: Project is vulnerable to: PYSEC-2008-2","Warn: Project is vulnerable to: PYSEC-2009-3","Warn: Project is vulnerable to: PYSEC-2015-11","Warn: Project is vulnerable to: PYSEC-2015-7","Warn: Project is vulnerable to: PYSEC-2016-18","Warn: Project is vulnerable to: PYSEC-2022-304","Warn: Project is vulnerable to: GHSA-gw84-84pc-xp82","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5"],"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-18T16:38:37.695Z","repository_id":45351723,"created_at":"2025-08-18T16:38:37.695Z","updated_at":"2025-08-18T16:38:37.695Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271509525,"owners_count":24772121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-rest-framework","hashids"],"created_at":"2025-08-22T22:01:33.377Z","updated_at":"2025-08-22T22:02:24.992Z","avatar_url":"https://github.com/evenicoulddoit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django REST framework serializer extensions\n**A collection of useful tools to DRY up your Django Rest Framework serializers**\n\nFull documentation: http://django-rest-framework-serializer-extensions.readthedocs.io/\n\n[![build-status-image]][gh-actions]\n[![coverage-status-image]][codecov]\n[![pypi-version]][pypi]\n\n\n## Overview\nSerializer extensions reduces the need for *very similar* serializers, by\nallowing the fields to be defined on a *per-view/request* basis. Fields can be\nwhitelisted, blacklisted, and child serializers can be optionally expanded.\nWhatever fields you choose to use, your querysets can be *optimized\nautomatically* to make the fewest database calls possible.\n\nSupport for [HashIds](https://github.com/davidaurelio/hashids-python) is\nalso provided. If you're currently exposing your internal IDs over a public\nAPI, we suggest you consider switching to HashIds instead.\n\n**:star: Lovingly open-sourced by [Housekeep](https://housekeep.com).**\n\n## Requirements\nTested against:\n\n* Python (3.8, 3.9, 3.10, 3.11, 3.12)\n* [Django](https://github.com/django/django) (3.2, 4.2, 5.0)\n* [Django REST Framework](https://github.com/tomchristie/django-rest-framework) \n  (3.12, 3.13, 3.14, 3.15). Note Django REST Framework 3.15 is the first version to\n  officially support Django 4.2+.\n* [HashIds](https://github.com/davidaurelio/hashids-python) (\u003e1.0)\n\n\n## Installation\nInstall using `pip`:\n\n```bash\n$ pip install djangorestframework-serializer-extensions\n```\n\nAnd add `rest_framework_serializer_extensions` to your `INSTALLED_APPS` setting:\n\n```py\nINSTALLED_APPS = (\n    ...\n    'rest_framework_serializer_extensions'\n)\n```\n\n\n## Basic Usage\nTo activate the serializer extensions, add the `SerializerExtensionsMixin` to your serializers:\n\n```py\n# serializers.py\nfrom rest_framework.serializers import ModelSerializer\nfrom rest_framework_serializer_extensions.serializers import SerializerExtensionsMixin\n\n...\n\nclass OwnerSerializer(SerializerExtensionsMixin, ModelSerializer):\n    class Meta:\n        model = models.Owner\n        fields = ('id', 'name')\n        expandable_fields = dict(\n            organization=OrganizationSerializer,\n            cars=dict(\n                serializer=SkuSerializer,\n                many=True\n            )\n        )\n```\n\nAnd add the `SerializerExtensionsAPIViewMixin` to your API views:\n\n```py\nfrom rest_framework.generics import RetrieveAPIView\nfrom rest_framework_serializer_extensions.views import SerializerExtensionsAPIViewMixin\n\nclass RetriveOwnerAPIView(SerializerExtensionsAPIViewMixin, RetrieveAPIView):\n    ...\n```\n\n\n## Examples\nSerializer extensions allows your API to re-use your serializers to fit a\nvariety of use cases. The examples shown below use query parameters to\nmodify the response, but individual views can interact with your serializers\nin much the same way.\n\n```js\n\u003e\u003e\u003e GET /owner/x4F/\n{\n  \"id\": 'x4F',\n  \"name\": 'tyrell',\n  \"organization_id\": 'kgD'\n}\n```\n\n```js\n\u003e\u003e\u003e GET /owner/x4F/?expand=organization\n{\n  \"id\": 'x4F',\n  \"name\": 'tyrell',\n  \"organization_id\": 'kgD',\n  \"organization\": {\n    \"id\": \"kgD\",\n    \"name\": \"E Corp\"\n  }\n}\n```\n\n```js\n\u003e\u003e\u003e GET /owner/x4F/?expand=cars__model\u0026exclude=name\n{\n  \"id\": 'x4F',\n  \"organization_id\": 'kgD',\n  \"cars\": [\n    {\n      \"id\": \"wf9\",\n      \"variant\": \"P100D\",\n      \"model\": {\n        \"id\": \"ncX\",\n        \"name\": \"Model S\"\n      }\n    }\n  ]\n}\n```\n\n```js\n\u003e\u003e\u003e GET /owner/x4F/?expand=cars\u0026only=cars__variant\n{\n  \"cars\": [\n    {\n      \"variant\": \"P100D\",\n    }\n  ]\n}\n```\n\n\n## Testing\nInstall testing requirements.\n\n```bash\n$ pip install -e .[test]\n```\n\nRun with pytest\n\n```bash\n$ pytest\n```\n\nYou can also use the excellent\n[tox](http://tox.readthedocs.org/en/latest/) testing tool to run the\ntests against all supported versions of Python and Django. Install tox\nglobally, and then simply run:\n\n```bash\n$ tox\n```\n\n\n## Documentation\nTo build the documentation, you’ll need to install `mkdocs`. These are included in the development extras:\n\n```bash\n$ pip install -e .[dev]\n```\n\nTo preview the documentation:\n\n```bash\n$ mkdocs serve\nRunning at: http://127.0.0.1:8000/\n```\n\nTo build the documentation:\n\n```bash\n$ mkdocs build\n```\n\n\n[build-status-image]: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions/actions/workflows/test.yml/badge.svg?branch=master\n[gh-actions]: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions/actions/workflows/test.yml?query=branch%3Amaster\n[coverage-status-image]: https://img.shields.io/codecov/c/github/evenicoulddoit/django-rest-framework-serializer-extensions/master.svg\n[codecov]: http://codecov.io/github/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master\n[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-serializer-extensions.svg\n[pypi]: https://pypi.python.org/pypi/djangorestframework-serializer-extensions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevenicoulddoit%2Fdjango-rest-framework-serializer-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevenicoulddoit%2Fdjango-rest-framework-serializer-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevenicoulddoit%2Fdjango-rest-framework-serializer-extensions/lists"}