Skip to main content

A DRF renderer to side-load relations

Project description

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.

Project details


Download files

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

Source Distribution

djangorestframework-inclusions-1.0.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file djangorestframework-inclusions-1.0.0.tar.gz.

File metadata

  • Download URL: djangorestframework-inclusions-1.0.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.9

File hashes

Hashes for djangorestframework-inclusions-1.0.0.tar.gz
Algorithm Hash digest
SHA256 90751fa10b085383d02dcdd3f7e9a87e9f1fb64a4f3fe3c20af1151d1ee0083a
MD5 fddf68ef2555cd5d95f01d01a8ce5802
BLAKE2b-256 328fe14030c828cf2d9dfbe452c10c89c3270fa4a39ce3697bc37c337ba0b4da

See more details on using hashes here.

File details

Details for the file djangorestframework_inclusions-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: djangorestframework_inclusions-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.9

File hashes

Hashes for djangorestframework_inclusions-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7251bcdf5a8a2d7e84e10c0511fb866b179c696ed2b46ff58ab2262b19c6d7d3
MD5 c98ffea08b1578f3da9e55367a6de813
BLAKE2b-256 f0fa41c69e73dcbfac99ac71fa9450facc6a36d308b885af033e4f9d211d9d19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page