Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A DRF renderer to side-load relations

Project description


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.


  • 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


pip install djangorestframework-inclusions


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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for djangorestframework-inclusions, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size djangorestframework_inclusions-1.1.0-py3-none-any.whl (17.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size djangorestframework-inclusions-1.1.0.tar.gz (14.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page