A DRF renderer to side-load relations
Project description
DRF-inclusions
A django-restframework renderer to side-load related resources.
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
Built Distribution
Close
Hashes for djangorestframework-inclusions-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9b35eeaf62c27e4770e5060d452166e1556d44621464cd76a4651c9e2e4d0a8 |
|
MD5 | faede46fff306844365502d599f27820 |
|
BLAKE2b-256 | 707e77b4e991d362d76b14a6da6e215fdf8f42cb1971c927916d8d2a2e67e1ef |
Close
Hashes for djangorestframework_inclusions-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3da739e5c65bd3374424b289f54a1cdd6bbbf23bc61ea602dbaaed67054f9cc6 |
|
MD5 | deb1facd3be575082d666554e050861c |
|
BLAKE2b-256 | 6923a49feae008a81dcb697f583a1cb7abc9ca8ab21b08f9afb3ca05c796bf73 |