# DRF-inclusions
A django-restframework renderer to side-load related resources.
[![Build status][build-status]][travis]
[![Coverage status][coverage]][codecov]
![Python versions][python-versions]
![Django versions][django-versions]
[![PyPI][pypi-version]][pypi]
[build-status]: https://travis-ci.org/isprojects/djangorestframework-inclusions.svg?branch=develop
[travis]: https://travis-ci.org/isprojects/djangorestframework-inclusions
[coverage]: https://codecov.io/gh/isprojects/djangorestframework-inclusions/branch/develop/graph/badge.svg
[codecov]: https://codecov.io/gh/isprojects/djangorestframework-inclusions
[python-versions]: https://img.shields.io/pypi/pyversions/djangorestframework-inclusions.svg
[django-versions]: https://img.shields.io/pypi/djversions/djangorestframework-inclusions.svg
[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-inclusions.svg
[pypi]: https://pypi.org/project/djangorestframework-inclusions/
One drawback of RESTful APIs is that you have to make _many_ calls to fetch all
the related resources. DRF-inclusions provides a custom renderer allowing you
to sideload those in a single, original request.
DRF-inclusions allows you to specify which serializers to use for included
resources, and via the query string the client can specify which resources
should be included.
Features:
* arbitrary depth
* option to include _all_ related resources
* de-duplication when the same object is found in multiple parent/related
objects
* an effort is made to retrieve related objects in as little DB queries as possible
## Installation
```bash
pip install djangorestframework-inclusions
```
## Usage
```python
from rest_framework_inclusions.renderer import InclusionJSONRenderer
class MySerializer(...):
inclusion_serializers = {"some_field": OtherSerializer}
class MyViewSet(...):
...
renderer_classes = (InclusionJSONRenderer,)
```
See the `tests` and `testapp` for advanced usage examples.
Raw data
{
"_id": null,
"home_page": "https://github.com/isprojects/djangorestframework-inclusions",
"name": "djangorestframework-inclusions",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "API,REST,lazy loading,django,djangorestframework",
"author": "ISPnext B.V., Sergei Maertens",
"author_email": "support@ispnext.com",
"download_url": "https://files.pythonhosted.org/packages/44/39/3f48cea275b3bb06735e2e18a706fa0a33dc43f9ec0b5bdda62312635807/djangorestframework-inclusions-1.2.0.tar.gz",
"platform": null,
"description": "# DRF-inclusions\n\nA django-restframework renderer to side-load related resources.\n\n[![Build status][build-status]][travis]\n[![Coverage status][coverage]][codecov]\n![Python versions][python-versions]\n![Django versions][django-versions]\n[![PyPI][pypi-version]][pypi]\n\n\n[build-status]: https://travis-ci.org/isprojects/djangorestframework-inclusions.svg?branch=develop\n[travis]: https://travis-ci.org/isprojects/djangorestframework-inclusions\n[coverage]: https://codecov.io/gh/isprojects/djangorestframework-inclusions/branch/develop/graph/badge.svg\n[codecov]: https://codecov.io/gh/isprojects/djangorestframework-inclusions\n[python-versions]: https://img.shields.io/pypi/pyversions/djangorestframework-inclusions.svg\n[django-versions]: https://img.shields.io/pypi/djversions/djangorestframework-inclusions.svg\n[pypi-version]: https://img.shields.io/pypi/v/djangorestframework-inclusions.svg\n[pypi]: https://pypi.org/project/djangorestframework-inclusions/\n\n\nOne drawback of RESTful APIs is that you have to make _many_ calls to fetch all\nthe related resources. DRF-inclusions provides a custom renderer allowing you\nto sideload those in a single, original request.\n\nDRF-inclusions allows you to specify which serializers to use for included\nresources, and via the query string the client can specify which resources\nshould be included.\n\nFeatures:\n\n* arbitrary depth\n* option to include _all_ related resources\n* de-duplication when the same object is found in multiple parent/related\n objects\n* an effort is made to retrieve related objects in as little DB queries as possible\n\n## Installation\n\n```bash\npip install djangorestframework-inclusions\n```\n\n## Usage\n\n```python\nfrom rest_framework_inclusions.renderer import InclusionJSONRenderer\n\n\nclass MySerializer(...):\n inclusion_serializers = {\"some_field\": OtherSerializer}\n\n\nclass MyViewSet(...):\n ...\n renderer_classes = (InclusionJSONRenderer,)\n```\n\nSee the `tests` and `testapp` for advanced usage examples.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A DRF renderer to side-load relations",
"version": "1.2.0",
"project_urls": {
"Homepage": "https://github.com/isprojects/djangorestframework-inclusions"
},
"split_keywords": [
"api",
"rest",
"lazy loading",
"django",
"djangorestframework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "658e822c0ff232e0251b92b578329770c598aae25a57f6fa64c0325caa326424",
"md5": "bf0943fe1b63a826b6cdf4c27b228b64",
"sha256": "f925a96c686b7afee1593a0b162d35f58aef0fa8c6ca0826e84d9a194438f89f"
},
"downloads": -1,
"filename": "djangorestframework_inclusions-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf0943fe1b63a826b6cdf4c27b228b64",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19586,
"upload_time": "2023-09-23T14:45:05",
"upload_time_iso_8601": "2023-09-23T14:45:05.059314Z",
"url": "https://files.pythonhosted.org/packages/65/8e/822c0ff232e0251b92b578329770c598aae25a57f6fa64c0325caa326424/djangorestframework_inclusions-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "44393f48cea275b3bb06735e2e18a706fa0a33dc43f9ec0b5bdda62312635807",
"md5": "680c9469da76f51715937b1351983c1b",
"sha256": "085249de77bafd861aa07152bdc8ddb431bb1cec9738d5b58f0894ba3c5aef5d"
},
"downloads": -1,
"filename": "djangorestframework-inclusions-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "680c9469da76f51715937b1351983c1b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16654,
"upload_time": "2023-09-23T14:45:06",
"upload_time_iso_8601": "2023-09-23T14:45:06.868006Z",
"url": "https://files.pythonhosted.org/packages/44/39/3f48cea275b3bb06735e2e18a706fa0a33dc43f9ec0b5bdda62312635807/djangorestframework-inclusions-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-23 14:45:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "isprojects",
"github_project": "djangorestframework-inclusions",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "djangorestframework-inclusions"
}