Skip to main content

DRF-inclusions

A django-restframework renderer to side-load related resources.

Build status Coverage status Python versions Django versions PyPI

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

pip install djangorestframework-inclusions

Usage

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.

Release files for djangorestframework-inclusions 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangorestframework-inclusions 1.2.0
File Size Uploaded
djangorestframework-inclusions-1.2.0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangorestframework-inclusions 1.2.0
File Interpreter ABI Platform
djangorestframework_inclusions-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.2 kB

Release files / djangorestframework-inclusions-1.2.0.tar.gz

Download URL djangorestframework-inclusions-1.2.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
085249de77bafd861aa07152bdc8ddb431bb1cec9738d5b58f0894ba3c5aef5d
BLAKE2b-256 checksum
How to use checksums
44393f48cea275b3bb06735e2e18a706fa0a33dc43f9ec0b5bdda62312635807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / djangorestframework_inclusions-1.2.0-py3-none-any.whl

Download URL djangorestframework_inclusions-1.2.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f925a96c686b7afee1593a0b162d35f58aef0fa8c6ca0826e84d9a194438f89f
BLAKE2b-256 checksum
How to use checksums
658e822c0ff232e0251b92b578329770c598aae25a57f6fa64c0325caa326424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page